爬虫入门

刚接触爬虫,跟着教程爬取了4399的网页
image
`from urllib.request import urlopen

url ="http://www.4399.com"
responce=urlopen(url)

with open("my4399.html",mode="w",encoding="gb2312") as f:
f.write(responce.read().decode("gb2312"))
print("over")
responce.close()`
代码
了解了python中的re--正则表达式模块
利用re模块爬取的豆瓣TOP250
image
正则表达式确实比较难手写,感觉更好的是了解语法,然后让ai生成
爬取的电影天堂
image
简单理解就是用程序来模拟用户获取网页的信息,模拟的越真实获取到的概率越大
爬取到学校官网的源代码
image

posted @ 2025-08-16 16:23  向恦  阅读(9)  评论(0)    收藏  举报