久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      正則爬取京東商品信息并打包成.exe可執(zhí)行程序

      本文爬取內容,輸入要搜索的關鍵字可自動爬取京東網站上相關商品的店鋪名稱,商品名稱,價格,爬取100頁(共100頁)

      代碼如下;

        import requests  import re  # 請求頭  headers = {    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'  }    def get_all(url,key):    for page in range(1,200,2):      params = {        'keyword':key,        'enc':'utf-8',        'page':page      }      num = int((int(page)+1)/2)      try:        response = requests.get(url=url,params=params,headers=headers)        # 轉碼        content = response.text.encode(response.encoding).decode(response.apparent_encoding)        data_all = re.findall('<div class="p-price">.*?<i>(.*?)</i>.*?<div class="p-name p-name-type-2">.*?title="(.*?)"'                   '.*?<div class="p-shop".*?title="(.*?)"',content,re.S)        for i in data_all:          with open(key + '.txt', 'a+', encoding='utf-8') as f:            f.write('店鋪名稱:' + i[2]+'n'+'商品名稱:'+i[1]+'n'+'價格:'+i[0]+'nn')          print('第'+str(num)+'頁'+'數(shù)據(jù)下載中....')      except Exception as e:        print(e)    if __name__ == '__main__':    print('輸入要搜索的內容,獲取京東商城里面的商品名稱,店鋪名稱,商品價格')    key = input('輸入搜索內容:')    url = 'https://search.jd.com/Search?'    get_all(url,key)

      打包成.exe可執(zhí)行文件。

      需要用到pyinstaller包pip下載;

      pip install pyinstaller

      在線制作一個.ico圖標,用來當程序圖片,把圖標和程序放在同一個文件夾下,

      正則爬取京東商品信息并打包成.exe可執(zhí)行程序

      正則爬取京東商品信息并打包成.exe可執(zhí)行程序

       

      在.py文件目錄下打開命令行窗口,執(zhí)行打包命令;

      E:練習最后階段