import urllib.request import ssl #取消全局SSL验证,不写这句 可能会报SSL验证失败 ssl._create_default_https_context = ssl._create_unverified_context chaper_url = "http://588ku.com/" headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0'} req = urllib.request.Request(url=chaper_url, headers=headers) the_page = urllib.request.urlopen(req) html = the_page.read() with open("588ku.txt",mode='wb') as f: f.write(html) print(html)
Python 使用Pycharm抓取网页
最新推荐文章于 2025-03-02 08:00:00 发布