3

I would like to download some weather information with python from: http://idojarasbudapest.hu/archivalt-idojaras, but I can not see the necessary informations until I don't press the submit button "Mehet". There is two information which I have to submit: Year ('ev'), and month ('ho').

As I understand, I have to POST a request with two parameters: 'ev' and 'ho', then the website should "send me" the requested informations.

The following code which I wrote, prints the original website's html code, not the requested one.

import requests
data= {'ev': '2016','ho': 'Január'}
r = requests.post('http://idojarasbudapest.hu/archivalt-idojaras', data=data)
print (r.text)

The html form looks like this:

The html form

Any idea, how to fix this? Thanks for any answer or suggestion.

asked Oct 15, 2017 at 11:55

2 Answers 2

5

From inspecting the post request sent by the browser when the "Mehet" button is pressed, I see that the arguments sent in the POST request have a different form than the ones you are posting via requests.

Firefox developer tools screenshot -- http://idojarasbudapest.hu/archivalt-idojaras

So perhaps change your code to something like this:

import requests
data= {'ev': '2016','ho': '01', 'button': 'Mehet'}
r = requests.post('http://idojarasbudapest.hu/archivalt-idojaras', data=data)
print (r.text)
answered Oct 15, 2017 at 12:05
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I was looking for that!:)
2

To your payload, add 'button': 'Mehet'.

data= {'ev': '2016', 'ho': '01', 'button': 'Mehet'}
answered Oct 15, 2017 at 12:03

2 Comments

I have tried this, but that did not solve the problem. What Odysseas mentioned is working. Thanks!
@ajlaj25 Oh yeah, I didn't realise, sorry. You have to submit the value of the option, which would be 01 for January. Will edit accordingly.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.