Home > other >  Small white consult, this should grab the content, how do you write the code? Why do I write return
Small white consult, this should grab the content, how do you write the code? Why do I write return

Time:09-21

760 & lt;/span> M & lt;/div>

/& lt;/span> 4 room 3 hall & lt; Span>/& lt;/span> 229.98 square meters & lt; Span>/& lt;/span> The south north & lt; Span>/& lt;/span> Hardcover & lt;/div>

Code:
Price=lj. Find_all (' div ', attrs={' class ':' price '})
Tp=[]
For a price in:
Atul gawande at the price1=et_text ()
Tp. Append (price1)

# extraction housing information
Info=lj. Find_all (' div ', attrs={' class ':' info '})

Hi=[]
A for b in the info:
Info1=b.s pan. The string
Hi. Append (info1)

Results:

Totalprice...
0 315...
1 630...
2 500...
3 940...
4 795...

CodePudding user response:

Class info inside the span tags inside without content, content outside the span, so, of course, is you pick up the empty, because your code is b.s pan. The string

CodePudding user response:

Oh, that is like, thank you, how to change the world, I write b.g et_text () is also wrong,,,,

CodePudding user response:

I recently to not make the crawler, but I see my previous blog is written like this:
 
Human_list=soup. The find (name="div", attrs={" class ":" c - the abstract "})
Human_list=STR (human_list)
Human_list=human_list. Replace (' & lt; Div & gt; ', "")
Human_list=human_list. Replace (" & lt;/div>" , "")
Human_list=human_list. Replace (" \ n ", "")
Print (human_list)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (N - N - N) of the original articles, follow BY CC 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/qq_40832960/article/details/103854145

Look at the second line, I am a direct STR (), should be ok

CodePudding user response:

Ok, thank you very much!
  • Related