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

  • 大小: 0.01M
    文件類型: .py
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-23
  • 語言: Python
  • 標簽: 其他??

資源簡介

untitled2.py

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
“““
Created?on?Mon?Aug?20?12:23:53?2018

@author:?linzhenglai
“““
#?-*-?coding:?utf-8?-*-
“““
Created?on?Mon?Aug?20?11:11:18?2018

@author:?linzhenglai
“““
#?-*-?coding:?utf-8?-*-
“““
Spyder?Editor

This?is?a?temporary?script?file.
“““

#?-*-?coding:?utf-8?-*-
“““
Spyder?Editor

This?is?a?temporary?script?file.
“““

import?time
import?requests
#爬取網(wǎng)頁時直接出現(xiàn)403,意思是沒有訪問權限
from?bs4?import?BeautifulSoup
import?json
#入口網(wǎng)頁
import?xlwt

url=‘http://chs.meituan.com/‘

headers={
????????‘Accept‘:‘text/htmlapplication/xhtml+xmlapplication/xml;q=0.9image/webpimage/apng*/*;q=0.8‘
????????‘Accept-Language‘:‘zh-CNzh;q=0.9‘
????????‘Cache-Control‘:‘max-age=0‘
????????‘Proxy-Connection‘:‘keep-alive‘
????????‘Host‘:‘chs.meituan.com‘
????????‘Referer‘:‘http://chs.meituan.com/‘
????????‘Upgrade-Insecure-Requests‘:‘1‘
????????‘User-Agent‘:‘Mozilla/5.0?(Windows?NT?6.1;?Win64;?x64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/67.0.3396.99?Safari/537.36‘
????????‘Content-Type‘:‘text/html;charset=utf-8‘
????????‘Cookie‘:?‘_lxsdk_cuid=164c9bed44ac8-0bf488e0cbc5d9-5b193413-1fa400-164c9bed44bc8;?__mta=248363576.1532393090021.1532393090021.1532393090021.1;?rvct=70%2C1;?ci=70;?iuuid=30CB504DBAC7CCDD72645E3809496C48229D8143D427C01A5532A4DDB0D42388;?cityname=%E9%95%BF%E6%B2%99;?_lxsdk=30CB504DBAC7CCDD72645E3809496C48229D8143D427C01A5532A4DDB0D42388;?_ga=GA1.2.1889738019.1532505689;?uuid=2b2adb1787947dbe0888.1534733150.0.0.0;?oc=d4TCN9aIiRPd6Py96Y94AGxfsjATZHPGsCDua9-Z_NQHsXDcp6WlG2x7iJpYzpSLttNvEucwm_D_SuJ7VRJkLcjqV6Nk8s_q3VyOJw5IsVJ6RJPL3qCgybGW3vxTkMHr9A4yChReTafbZ7f93F1PkCyUeFBQV4D-YXoVoFV5h3o;?_lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic;?client-id=97664882-24cd-4743-b21c-d25de878708e;?lat=28.189822;?lng=112.97422;?_lxsdk_s=165553df04a-bc8-311-ba7%7C%7C6‘
}

#with?open(r‘美團西安美食.csv‘“w“?newline=‘‘encoding=‘UTF-8‘)?as?csvfile
#獲取主頁源碼(獲取分類-美食、電影)
#def?get_start_links(url):
????#html=requests.get(url).text#發(fā)送請求獲取主頁文本
????#print?html
????#soup=BeautifulSoup(html‘lxml‘)#解析網(wǎng)頁
????#==$
????#
????#????#links=‘http://chs.meituan.com/meishi/?
???#?links=[link.find(‘span‘).find(‘a(chǎn)‘)[‘href‘]?for?link?in?soup.find_all(‘span‘class_=‘nav-text-wrapper‘)]
????#print?links
????#return?links
#獲取分類鏈接中間的店鋪id
#find:取第一個(返回一個具體的元素,沒有為null)find_all:匹配所有(返回列表,沒有返回[])
def?get_detail_id(category_url):
????html=requests.get(category_urlheaders=headers).text
????#print?html
????soup=BeautifulSoup(html‘lxml‘)#解析網(wǎng)頁
????#print?soup
????texts=soup.find_all(‘script‘)
????#print?texts
????text=texts[14].get_text().strip()
????#print?text
????text=text[19:-1]
????
????result1=json.loads(textencoding=‘utf-8‘)
????#print?result1
????result2=result1[‘poiLists‘]
????result3=result2[‘poiInfos‘]
????#print?result3
????Info_list=[]
????for?it?in?result3:
????????#print?it
????????Info_list.append(it[‘poiId‘]

評論

共有 條評論