Îá°®Æƽâ - 52pojie.cn

 ÕÒ»ØÃÜÂë
 ×¢²á[Register]

QQ怬

Ö»ÐèÒ»²½£¬¿ìËÙ¿ªÊ¼

²é¿´: 1732|»Ø¸´: 6
ÊÕÆð×ó²à

[ÇóÖú] ΪʲôС˵ÄÚÈÝÊÇ¿Õ°×ÄØ printÓÐÄÚÈÝ

[¸´ÖÆÁ´½Ó]
lihu5841314 ·¢±íÓÚ 2021-5-25 21:17
ÓÃprint£¨¡°page2¡±£©  ÄÜ¿´µ½Ã¿Ò»ÕµÄÄÚÈÝ
[Asm] ´¿Îı¾²é¿´ ¸´ÖÆ´úÂë
import  requests
import os
from lxml import  etree



headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
    }
url = "https://book.qidian.com/info/1025592578#Catalog"
page_text = requests.get(url=url,headers=headers).text
tree = etree.HTML(page_text)
#½âÎö³öÕ½ÚÃû³ÆºÍÏêÇéÒ³Url
li_list = tree.xpath('//*[@id="j-catalogWrap"]/div[2]/div/ul/li')
if not os.path.exists('./dagelao'):
     os.mkdir('./dagelao')
for li in li_list:
   detail_url= "https:"+  li.xpath('./a/@href')[0]
   name = li.xpath('./a/text()')[0] + ".text"
   detaii_page_text = requests.get(url=detail_url,headers=headers).text
   detail_tree = etree.HTML(detaii_page_text)
   detail_text = detail_tree.xpath('//*[@class="text-wrap"]/div/div[2]//text()')
   for page2 in detail_text:
        path = './dagelao/' + name
        with open(path,"w",encoding="UTF-8") as pf:
            pf.write(page2)

   print(name,"ÏÂÔØÍê±Ï")

·¢ÌûÇ°ÒªÉÆÓá¾ÂÛ̳ËÑË÷¡¿¹¦ÄÜ£¬ÄÇÀï¿ÉÄÜ»áÓÐÄãÒªÕҵĴ𰸻òÕßÒѾ­ÓÐÈË·¢²¼¹ýÏàͬÄÚÈÝÁË£¬ÇëÎðÖظ´·¢Ìû¡£

 Â¥Ö÷| lihu5841314 ·¢±íÓÚ 2021-5-25 21:30
ÕÒµ½Ô­ÒòÁË  with open(path,"w",encoding="UTF-8")   µÄ¡°w¡± ²»¶Ô  »»³Éa  ¾Í¶ÔÁË

w ÿ´ÎÑ­»·¶¼°ÑÉϴεÄÎļþɾµôÖØд´½¨
fanvalen ·¢±íÓÚ 2021-5-25 21:34
Á½¸öµØ·½´íÁË
µÚÒ»¸ö×îΪÖÂÃü
with open(path,"w",encoding="UTF-8") as pf:
ÄãÕâÀïÊÇ´ÓÁбíÀïÑ­»·È¡³öÎı¾ÒªÓÃ×·¼ÓģʽҲ¾ÍÊÇa+

È»ºóÄãµÄÎļþÃûºó׺¾ÓÈ»ÊÇtext£¬ÂèµÄÎÒ²îµãû´ò¿ª Îı¾ÊÇtxt

Ãâ·ÑÆÀ·Ö

²ÎÓëÈËÊý 1ÈÈÐÄÖµ +1 ÊÕÆð ÀíÓÉ
ppszxc + 1 ÓÃÐÄÌÖÂÛ£¬¹²»ñÌáÉý£¡

²é¿´È«²¿ÆÀ·Ö

 Â¥Ö÷| lihu5841314 ·¢±íÓÚ 2021-5-25 22:04
²»ÖªµÀ¸Ä³Éɶ ·¢±íÓÚ 2021-5-26 09:25
fanvalen ·¢±íÓÚ 2021-5-25 21:34
Á½¸öµØ·½´íÁË
µÚÒ»¸ö×îΪÖÂÃü
with open(path,"w",encoding="UTF-8") as pf:

дÎļþ×îºÃ»¹ÊǸijÉÒ»´ÎÐÔдÈëµ½ÎļþÐÔÄܱȽϺðɡ£
ÖªÐÄ ·¢±íÓÚ 2021-5-26 09:44
tanzhiwei ·¢±íÓÚ 2021-5-26 09:25
дÎļþ×îºÃ»¹ÊǸijÉÒ»´ÎÐÔдÈëµ½ÎļþÐÔÄܱȽϺðɡ£

¿´ÇëÇóµÄÊý¾ÝÇé¿ö°É¡£·Ö¶à´ÎÇëÇóµ½µÄÄÚÈݲ»±£´æµÄ»°¾ÍÔÚÄÚ´æÀÈç¹û³ÌÐò±¼À£Ò»Ï¾Ͱ׸ÉÁË¡£with»á×Ô¼ºÔÚºÏÊʵĽڵã¹Ø±ÕÎļþµÄ¡£ÍËÒ»Íò²½½²£¬Ð¡ÏîÄ¿²»Óÿ¼ÂÇÕâô¶à¡£
npfjcg ·¢±íÓÚ 2021-5-26 10:29
Èç¹ûÄÚ´æÓÐÌõ¼þµÄ»°£¬¿ÉÒÔ°ÑÅÀÈ¡ÏÂÀ´µÄÎı¾´æµ½ÄÚ´æÀ±ÈÈç°´Ðдæ½ølist»òÕßÊÇ´æ½ø×Ö·û´®Àï
ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | ×¢²á[Register]

±¾°æ»ý·Ö¹æÔò

·µ»ØÁбí

RSS¶©ÔÄ|СºÚÎÝ|´¦·£¼Ç¼|ÁªÏµÎÒÃÇ|Îá°®Æƽâ - LCG - LSG ( ¾©ICP±¸16042023ºÅ | ¾©¹«Íø°²±¸ 11010502030087ºÅ )

GMT+8, 2024-11-26 02:43

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí