xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 1KB
    文件類型: .py
    金幣: 1
    下載: 1 次
    發布日期: 2021-06-13
  • 語言: Python
  • 標簽: python??baidu??title??url??

資源簡介

Python腳本用于獲取百度搜索結果中的標題和URL。 輸入:百度關鍵詞及搜索頁面數 輸出:標題和URL

資源截圖

代碼片段和文件信息

#encoding:?utf-8
#采集SERP搜索結果標題
import?urllib2
from?bs4?import?BeautifulSoup

#獲取title和url
def?GettitleUrl(urlres_titleres_urlbShowRes):
??try:
????##獲取Html源碼
????req?=?urllib2.Request(url)
????response=?urllib2.urlopen(reqNone3)#設置超時時間
????data?=?response.read()#.decode(‘utf-8‘‘ignore‘)
????##提取搜索結果SERP的標題和鏈接
????soup?=?BeautifulSoup(‘‘.join(data)‘lxml‘)
????for?i?in?soup.findAll(“h3“):
??????temp_title?=?i.a.text.encode(“utf-8“)
??????temp_url?=?i.a.get(‘href‘)
??????if?bShowRes==1:
????????print?temp_title
????????print?temp_url
??????res_title.append(temp_title)
??????res_url.append(temp_url)
??except:
??????pass

評論

共有 條評論