Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load a BeautifulSoup page parser?

help please download the specified page and find her element with id =''login ". necessarily need to use for the query module request

import pprint
import requests

import bs4

url = 'http://forum.saransk.ru/'
html = requests.get(url)
#print(html.text)
soup = bs4.BeautifulSoup(html)
loginForm = soup.find('form', {'id': 'login'})

pprint.pprint(loginForm)

error message:

Traceback (most recent call last): File "C:\VINT\OPENSERVER\OpenServer\domains\localhost\python\parse_html\4_auth\q.py", line 9, in soup = bs4.BeautifulSoup(html) File "C:\Python33\lib\site-packages\bs4__init__.py", line 162, in init elif len(markup) <= 256: TypeError: object of type 'Response' has no len()

like image 986
Sergey Avatar asked Dec 04 '22 07:12

Sergey


1 Answers

You need to pass the actual html not the request :

soup = bs4.BeautifulSoup(html.text)
like image 164
OneOfOne Avatar answered Dec 08 '22 05:12

OneOfOne