猫史档案馆


【Python作品分享】正则表达式爬虫(自制)【求助帖】

用户:阿迁pils阿迁pils查看:0 回复:0 评论:0 创建时间:2022-10-29T15:06:17


【作品展示】

center_image

 

【作品介绍】

啥也不是 瞎写的 LLL

 

【作品源代码】

import re
import requests

url = 'https://gratisography.com/photos/photos/page/1/'

responce = requests.get(url)
text = responce.text
a = 1
# rule = re.compile()
img_url_list = re.findall(r'src="(https://gratisography.com/wp-content/uploads.*?jpg)"',text)
for img_url in img_url_list:
    print(img_url)
    # img = requests.get(img_url).content
    # with open('D:/爬虫/%d.jpg'%a,'wb') as f:
    #     f.write(img)
    # a += 1

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页