Python Forum
requests post/get to HTML form - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: requests post/get to HTML form (/thread-22193.html)



requests post/get to HTML form - mrdominikku - Nov-03-2019

Hey there,

I have application which pulls lottery numbers from official website of lottery.

Website allows search previous lottery games by it's date.

I have tried it by using
requests
module but after request was sent I still receiving website output before submit.

Could take a look and guide me what I am doing wrong?

from bs4 import BeautifulSoup
import requests

form = 'form-a4251ea9cfceec0e0003ead731f36e8d'
date = "2019-03-02"
web_page = 'https://www.lotto.pl/lotto/wyniki-i-wygrane/wyszukaj?'

request_id = str.format('data_losowania%5Bdate%5D={0}&op=&form_build_id={1}&form_id=lotto_wyszukaj_form', date.format("yyyy-mm-dd"), form)

def import_lotto():

    response = requests.get(web_page+request_id)

    soup = BeautifulSoup(response.content, 'html.parser')

    print(soup)



RE: requests post/get to HTML form - Larz60+ - Nov-03-2019

Quote:Requests is an elegant and simple HTTP library for Python, built for human beings.
Requests is just that. I don't know what you expect to get other than html, which is what is does.
I suggest that you read: https://requests.kennethreitz.org/en/master/

I strongly suggest that you vist:
Web scraping part 1
Web scraping part 2