日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Python爬取网站用户手机号_设计师的福利,python爬取素材网站

發布時間:2025/3/20 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python爬取网站用户手机号_设计师的福利,python爬取素材网站 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

本文的文字及圖片來源于網絡,僅供學習、交流使用,不具有任何商業用途,如有問題請及時聯系我們以作處理。

基本環境配置

  • python 3.6
  • pycharm
  • requests
  • parsel

相關模塊pip安裝即可

確定網站目標


基本常規操作,F12打開開發者工具,分析網頁


網頁返回的數據 ,都是一堆亂碼,再寫代碼的時候可以轉一下編碼就好了
靜態網頁都是非常簡單的,是可以直接抓取到自己想要的數據的

請求網頁

import requestsimport reurl = 'http://www.sccnn.com/shiliangtuku/default({}).html'.format(page)headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'}response = requests.get(url=url, headers=headers)response.encoding = response.apparent_encoding

分析網頁,解析數據

import parselr = re.findall('', response.text)urls = r[2:]for i in urls: page_url = 'http://www.sccnn.com' + i response_2 = requests.get(url=page_url, headers=headers) response_2.encoding = response_2.apparent_encoding selector = parsel.Selector(response_2.text) title = selector.css('#LeftBox h2::text').get() img_url = selector.css('#LeftBox .PhotoDiv img::attr(src)').get()

保存數據

def downlaod(title, url): path = 'D:pythondemo素材網站img' + title + '.jpg' response = requests.get(url=url, headers=headers) with open(path, mode='wb') as f: f.write(response.content) print('正在下載{}'.format(title))

實現效果

完整項目代碼后臺私信小編01獲取!

總結

以上是生活随笔為你收集整理的Python爬取网站用户手机号_设计师的福利,python爬取素材网站的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。