1つの インポート要求 2 から pyqueryのインポートPQとしてPyQuery 3 4 デフ:GET_CONTENT(A) 5 応答= requests.get(A) 6 #プリント(STR(応答)) 7 response.encoding = ' GBKの' 8 #プリント(応答。テキスト) 9 DOC = PQ(response.text) 10 テキスト= DOC(' #1 content.showtxt ' ) 11 =のSTR(テキスト) 12 B = a.replace("#13は&; 13は、&#あり; " " \ N- ").replace(' A '、' \ N- ').replace(" <スクリプト> chaptererror (); </ script>の<BR/>ブック発射ドメインを覚えておいてください:。www.biqugexsw.com新たなネットワークのURLを読み取るペンファンクラブモバイル版:m.biqugexsw.com </ DIV>を' ' ')。 (置き換え' \ XA0 '、'').replace(' <DIV ID = "コンテンツ"クラス= "showtxtを"> '、'' ) 13が オープン=(Uファイル" Fを:\ Pythonの\小説の\ 1.TXT ' ' A + " ) 14 File.close() 15 DEF get_mulu(): 16 index_url = ' https://www.biqugexsw.com/75_75362/ ' #書籍あるいは他のページ 17 応答= requests.get(index_url) 18れる response.encoding = 応答。 apparent_encoding 。19 DOCは= PQ(response.text) 20である のURL = DOC(' div.listmainのA ' ) 21がある ために I で)(urls.items: 22は = ' https://www.biqugexsw.com/ ' + I. attr.href#各章のURL取得 23 GET_CONTENT(A) 24 印刷(" 成功" ) 25 #印刷(A) 26 get_mulu()
最近の研究の爬虫類、練習クロールペンファンクラブ小説。
完璧なものにするには:
ブラウザシミュレーションアクセス
非同期クロール
booknameを取得
正規表現