#-*- coding:utf-8 -*- #encoding:utf8 import urllib.request import re import chardet def getHtml(url): #html=urllib.request.urlopen(url).read() #charset=chardet.detect(html) #html=html.decode("utf-8") #print(charset) req = urllib.request.Request(url) req.add_header(
简单的爬虫,爬取火狐主页的图片并保存到本地
最新推荐文章于 2023-12-22 21:42:43 发布
使用Python的urllib.request模块和正则表达式,爬取火狐主页的图片URL,然后将其下载并保存为.jpg文件。设置User-Agent以模拟浏览器请求,避免被网站屏蔽。
摘要由CSDN通过智能技术生成