<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ##爬蟲 這一章將會介紹使用一些新的模塊(optparse,spider)去完成一個爬蟲的web應用。爬蟲其實就是一個枚舉出一個網站上面的所有鏈接,以幫助你創建一個網站地圖的web應用程序。而使用Python則可以很快的幫助你開發出一個爬蟲腳本. 你可以創建一個爬蟲腳本通過href標簽對請求的響應內容進行解析,并且可以在解析的同時創建一個新的請求,你還可以直接調用spider模塊來實現,這樣就不需要自己去寫那樣多的代碼了: ![crawler.py](img/0x601.png) 這里有幾個參數你需要去了解一下,不然上面這段腳本是無法成功運行的:"myspider(b=URL.strip(), w=200, d=5, t=5)"這個函數將會返回兩個列表:子url鏈接與路徑。你也可以自己修改myspider函數里面的參數: b — 基本的web URL(默認: 無) w — 抓取的數量 (默認: 200) d — 抓取的深度層級 (默認: 5) t — 設置線程數 (默認: 無) 這篇文章主要是先介紹一個web爬蟲的入門基礎,web資源千變萬化。所以未來在博客的其他文章里面再深入的講述攻擊web服務器一些更高級的案例; 圖中的python爬蟲腳本代碼片段: ``` #!/usr/bin/python from spider import webspider as myspider import sys, optparse def crawler(URLs): for line in open(URLs, 'r'): URL = line.strip() links = myspider(b=URL.strip(), w=200, d=5, t=5) link_count = len(links[0]) out = URL+": has a link count of "+str(link_count) print "[+] Web Crawl Results for: "+URL print out for item in links[1]: print item def main(): # optparse模塊允許你通過參數選項來調用那段代碼 # 這里我使用 '-r'選項并且內容會保存在URLs變量里面 # 當使用-r參數的使用腳本會去讀取指定的文件夾 parser = optparse.OptionParser(sys.argv[0]+' '+ \ '-r <file_with URLs>') parser.add_option('-r', dest='URLs', type='string', \ help='specify target file with URLs') (options, args) = parser.parse_args() URLs=options.URLs if (URLs == None): print parser.usage sys.exit(0) else: crawler(URLs) if __name__ == "__main__": main() ``` * [spider模塊](https://pypi.python.org/pypi/spider.py/)
                  <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>

                              哎呀哎呀视频在线观看