Multi POST-Abfrage (Sitzungsmodus)
Ich versuche, diese @ abzufragSeite? ˅, um die Liste der Angebote zu erhalten. Das Problem ist, dass wir 2 Formulare (2 POST-Abfragen) ausfüllen müssen, bevor wir das endgültige Ergebnis erhalten.
Das was ich bisher gemacht habe:
Zunächst sende ich den ersten POST nach dem Setzen der Cookies:
library(httr)
set_cookies(.cookies = c(a = "1", b = "2"))
first_url <- "https://compare.switchon.vic.gov.au/submit"
body <- list(energy_category="electricity",
location="home",
"location-home"="shift",
"retailer-company"="",
postcode="3000",
distributor=7,
zone=1,
energy_concession=0,
"file-provider"="",
solar=0,
solar_feedin_tariff="",
disclaimer_chkbox="disclaimer_selected")
qr<- POST(first_url,
encode="form",
body=body)
Versuchen Sie dann, die Angebote mit der zweiten Post-Abfrage abzurufen:
gov_url <- "https://compare.switchon.vic.gov.au/energy_questionnaire/submit"
qr1<- POST(gov_url,
encode="form",
body=list(`person-count`=1,
`room-count`=1,
`refrigerator-count`=1,
`gas-type`=4,
`pool-heating`=0,
spaceheating="none",
spacecooling="none",
`cloth-dryer`=0,
waterheating="other"),
set_cookies(a = 1, b = 2))
)
library(XML)
dc <- htmlParse(qr1)
Aber leider erhalte ich eine Nachricht, die das Ende der Sitzung anzeigt. Vielen Dank für jede Hilfe, um dieses Problem zu lösen.
update Cookies hinzufügen:Ich habe die Cookies und das Zwischen-GET hinzugefügt, aber ich habe immer noch keine Ergebnisse.
library(httr)
first_url <- "https://compare.switchon.vic.gov.au/submit"
body <- list(energy_category="electricity",
location="home",
"location-home"="shift",
"retailer-company"="",
postcode=3000,
distributor=7,
zone=1,
energy_concession=0,
"file-provider"="",
solar=0,
solar_feedin_tariff="",
disclaimer_chkbox="disclaimer_selected")
qr<- POST(first_url,
encode="form",
body=body,
config=set_cookies(a = 1, b = 2))
xx <- GET("https://compare.switchon.vic.gov.au/energy_questionnaire",config=set_cookies(a = 1, b = 2))
gov_url <- "https://compare.switchon.vic.gov.au/energy_questionnaire/submit"
qr1<- POST(gov_url,
encode="form",
body=list(
`person-count`=1,
`room-count`=1,
`refrigerator-count`=1,
`gas-type`=4,
`pool-heating`=0,
spaceheating="none",
spacecooling="none",
`cloth-dryer`=0,
waterheating="other"),
config=set_cookies(a = 1, b, = 2))
library(XML)
dc <- htmlParse(qr1)