91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-01-02
  • 語言: Python
  • 標簽: Pytho??爬取51job??

資源簡介

此資源用xpath的方法來解析網頁的內容,詳細的介紹了下載網頁、解析數據、將數據存入表格的過程。希望能給到你借鑒。

資源截圖

代碼片段和文件信息

#?-*-?coding:utf-8?-*-

import?requests
from?fake_useragent?import?UserAgent
agent=UserAgent()
#當用到xpath時需要引入此包
from?lxml?import?etree

#下載
url=“http://search.51job.com/list/010000%252C020000%252C180200%252C200200000000000000999python21.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99°reefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare=“

response?=?requests.get(url
??????????????????????????????????????????headers?=?{“User-Agent“:agent.random}
??????????????????????)
#設置編碼格式
response.encoding=response.apparent_encoding

#?解析
#?root可理解為網頁本身
root?=?etree.HTML(response.text)
#用xpath返回的是一個列表
div_list?=?root.xpath(‘//div[@class=“dw_table

評論

共有 條評論