360搜索主页爬虫
- # encoding: utf-8
- import urllib.request
- import urllib.parse
- url = "https://www.so.com/s?q="
- keyword = input("请输入搜索关键词")
- keyword = urllib.parse.quote(keyword)
- urlkeyword = url+keyword
- print(urlkeyword)
- response = urllib.request.urlopen(url=urlkeyword)
- content = response.read()
- print(content)
- html = content.decode(\'UTF-8\')
- print(html)
- with open("360shanxijiaotong.html", "w", encoding="utf-8") as f:
- f.write(html)
版权声明:本文为hhct原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。