Python Forum

Full Version: requests post/get to HTML form
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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