gpt4 book ai didi

R:用 httr 模拟复杂形式

转载 作者:行者123 更新时间:2023-12-04 09:16:30 26 4
gpt4 key购买 nike

我正在尝试获得 that form 的结果与 httr .

看了form results ,我尝试了以下方法:

library(httr)
library(stringr)

r = str_c("http://www.memoiredeshommes.sga.defense.gouv.fr/fr/arkotheque/",
"client/mdh/base_morts_pour_la_france_premiere_guerre/index.php")

q = list(
"action" = 1,
"todo" = "rechercher",
"le_id" = "",
"multisite" = "",
"r_c_nom" = "mo",
"r_c_nom_like" = 1,
"r_c_prenom" = "",
"r_c_prenom_like" = 1,
"r_c_naissance_jour_mois_annee_jj_debut" = "",
"r_c_naissance_jour_mois_annee_mm_debut" = "",
"r_c_naissance_jour_mois_annee_yyyy_debut" = 1890,
"r_c_naissance_jour_mois_annee_jj_fin" = "",
"r_c_naissance_jour_mois_annee_mm_fin" = "",
"r_c_naissance_jour_mois_annee_yyyy_fin" = "",
"r_c_id_naissance_departement" = "",
"hidden_c_id_naissance_departement" = "",
"r_c_id_naissance_pays" = "",
"hidden_c_id_naissance_pays" = "",
"r_annot_c_id_grade" = "",
"hidden_c_id_grade" = "",
"r_annot_c_id_unite" = "",
"hidden_c_id_unite" = "",
"r_annot_c_id_recrutement_bureau" = "",
"hidden_c_id_recrutement_bureau" = "",
"r_annot_c_classe" = "",
"r_annot_c_recrutement_matricule" = "",
"r_annot_c_id_naissance_lieu" = "",
"hidden_c_id_naissance_lieu" = "",
"r_annot_c_deces_jour_mois_annee_jj_debut" = "",
"r_annot_c_deces_jour_mois_annee_mm_debut" = "",
"r_annot_c_deces_jour_mois_annee_yyyy_debut" = "",
"r_annot_c_deces_jour_mois_annee_jj_fin" = "",
"r_annot_c_deces_jour_mois_annee_mm_fin" = "",
"r_annot_c_deces_jour_mois_annee_yyyy_fin" = "",
"r_annot_c_id_deces_lieu" = "",
"hidden_c_id_deces_lieu" = "",
"r_annot_c_deces_lieu_complement" = "",
"r_annot_c_deces_lieu_complement_like" = 1,
"r_annot_c_id_deces_departement" = "",
"hidden_c_id_deces_departement" = "",
"r_annot_c_id_deces_pays" = "",
"hidden_c_id_deces_pays" = "",
"r_annot_c_id_transcription_etablissement_lieu" = "",
"hidden_c_id_transcription_etablissement_lieu" = "",
"r_annot_c_id_transcription_etablissement_departement" = "",
"hidden_c_id_transcription_etablissement_departement" = "",
"r_annot_c_id_transcription_etablissement_pays" = "",
"hidden_c_id_transcription_etablissement_pays" = ""
)

t = GET(r, query = q, verbose())
writeLines(content(t, "text", encoding = "UTF-8"), "~/Desktop/test.html")

......根本不起作用(我得到的是 NA )。

我究竟做错了什么?

最佳答案

你可以这样试试

library(rvest)
html_session(url) %>%
rvest:::request_POST(url, body = q, encode = "form") %>%
read_html %>%
html_table
# [[1]]
# Nom Prénom(s) Date de naissance Département/Pays de naissance Détail Images Panier Lien Fiche annotée
# 1 MOAL Alain Marc 10-08-1890 29 - Finistère Détail Visualiser Panier Ark oui
# 2 MOAL Jean 22-12-1890 29 - Finistère Détail Visualiser Panier Ark oui
# 3 MOAL Joseph Marie 29-04-1890 29 - Finistère Détail Visualiser Panier Ark oui
# 4 MOALIC Pierre Joseph Marie 05-04-1890 29 - Finistère Détail Visualiser Panier Ark oui
# ...

关于R:用 httr 模拟复杂形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40327657/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com