<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                原本想升一下級,用一下creep神馬的,但是正則今天突然出了點小問題,我就生氣了,就用正則抓取了一下。 這個正則可以用re.search 或者 re.findall都可以,我比較喜歡用search因為可以直接提取結果不用在過濾了。 代碼如下,這個小爬爬比較簡單。 ~~~ #-*- coding:utf-8 -*- import urllib2 import json import re SearchIphoneUrl = 'http://search.jd.com/Search?keyword=%E8%8B%B9%E6%9E%9C%E6%89%8B%E6%9C%BA&enc=utf-8&qr=&qrst=UNEXPAND&as_key=title_key%2C%2C%E6%89%8B%E6%9C%BA&rt=1&stop=1&click=&psort=1&page=1' header = {'User-Agent':'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 SE 2.X MetaSr 1.0','Accept':'*/*'} def getHtmlSrc(url,header): req = urllib2.Request(url,header) res = urllib2.urlopen(url,timeout = 5) htmlSrc = res.read() return htmlSrc def saveHtmlSrc(url): html = getHtmlSrc(url,header) with open('jd_iphone.txt','w') as f: f.write(html) saveHtmlSrc(SearchIphoneUrl) print '++++++++++++++++++++京東放養的爬蟲++++++++++++++++++++' with open('jd_iphone.txt','r') as fhtml: localhtml = fhtml.read()#.replace("'",'"').replace(' ','') for skuid in re.findall('<li sku="\d+">',localhtml): #商品編號 sku = skuid.split('"')[1] #手機名稱 pname = re.search('''<font class="skcolor_ljg">蘋果</font>(.*?)<font class="skcolor_ljg">''',localhtml) # 正則取商品名稱html #手機價格 price = re.search('''<strong class="J_%s" data-price="(.*?)">'''%sku,localhtml) if(pname!='' and price!=''): print "商品編號:%s"%sku print "名稱:%s\n價格:%s\n\n"%(pname.group(1),price.group(1)) print '++++++++++++++++++++京東放養的爬蟲++++++++++++++++++++' ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看