Home > database >  Python crawler
Python crawler

Time:01-26

Where we want to ask next is

CodePudding user response:

The from urllib. Request the import request, urlopen
The from urllib. Parse the import urlencode
# read HTML
Def get_html () :
Headers={
"The user-agent: Mozilla/5.0 (Windows NT 10.0; Win64. X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 "
}
Request=request (url, headers=headers)
The response=urlopen (request)
Print (response. The read (). The decode ())
Return the response. The read ()
Def save_html () :
Pass


Def the main () :
Get_html (" https://tieba.baidu.com/f? Fr=wwwt& Ie=utf-8 & amp; 9 kw B0 E5=% % % a % E5 A0 E5 A6 AD % % % % % 82 ")


If __name__=="__main__ ':
main()
  • Related