Home > other >  Beginners python crawler
Beginners python crawler

Time:10-10

Turn to the great god, why have only one information

CodePudding user response:

Circulation outside the print?

CodePudding user response:

In addition, give you a simple way to
 the from simplified_scrapy. Simplified_doc import SimplifiedDoc 
The from simplified_scrapy. Request the import the req

HTML=the req. Get (' https://news.sogou.com/news? AB BA query=% % % % % B9 FA D7 CA C2 B1 C9 D4 % % % % % % BE C1 B0 C7 D3 % % % % % D0 & amp; Mode=1 & amp; W=01025001 & amp; Oq=& amp; Ri=0 & amp; Sourceid=sugg& Sut=0 & amp; Sst0=1574739190312 & amp; LKT=2 c0%0% 2 c0 & amp; P=40240100 ')

Doc=SimplifiedDoc ()
LST=doc. GetElementsByClass (' vrwrap, HTML)
For the item in LST:
A=doc. GetElementByTag (' a ', item. InnerHtml)
Print (a.h ref, a.t ext)
Info=doc. GetElementByClass (' news - from 'item. InnerHtml)
If (info) :
Info=info. Text. The split ()
Print (info)

CodePudding user response:

Web pages with regular less, a little let you to write a regular change,

CodePudding user response:

refer to the second floor dabingsou response:
in addition, give you a simple way to
 the from simplified_scrapy. Simplified_doc import SimplifiedDoc 
The from simplified_scrapy. Request the import the req

HTML=the req. Get (' https://news.sogou.com/news? AB BA query=% % % % % B9 FA D7 CA C2 B1 C9 D4 % % % % % % BE C1 B0 C7 D3 % % % % % D0 & amp; Mode=1 & amp; W=01025001 & amp; Oq=& amp; Ri=0 & amp; Sourceid=sugg& Sut=0 & amp; Sst0=1574739190312 & amp; LKT=2 c0%0% 2 c0 & amp; P=40240100 ')

Doc=SimplifiedDoc ()
LST=doc. GetElementsByClass (' vrwrap, HTML)
For the item in LST:
A=doc. GetElementByTag (' a ', item. InnerHtml)
Print (a.h ref, a.t ext)
Info=doc. GetElementByClass (' news - from 'item. InnerHtml)
If (info) :
Info=info. Text. The split ()
Print (info)
thank you

CodePudding user response:

reference bubble pepper pork reply: 3/f
page with regular less, let you to write a little bit of change regular,
don't know much about ah, followed the book to school

CodePudding user response:

With a regular is good than xpath intuitive, if use of good, can write a more general than xpath method

CodePudding user response:

Print, adding a indentation to loop
  • Related