Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

beautiful soup catch this

After many years first time i need help on scraping my brain unfunctional right now 🤮

[Image: 2W8xtUU.png]


Code
<body contenteditable="true" dir="ltr" class="">

<div>text text</div>
<div>text text</div>
<div>text text</div>
<div>text text</div>
<div>text text</div>

</body>


How can i get inside text from this.
If you're trying to get the "SOMETHING SOMETHING SOMETHING" text (clarify please):

Code
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')

result = soup.find('body')
(Apr 16, 2020 04:00 PM)4Txe4y33C9zvNhMj Wrote:  If you're trying to get the "SOMETHING SOMETHING SOMETHING" text (clarify please):

Code
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')

result = soup.find('body')

yeap sorry you are right i just update question, all div tags.
(Apr 16, 2020 04:29 PM)SIM-1866423 Wrote:  yeap sorry you are right i just update question, all div tags.

Updated:

Code
from bs4 import BeautifulSoup
soup = BeautifulSoup(html)

for div in soup.find_all("div"):
  print("content: {}".format(div.text))
(Apr 16, 2020 04:49 PM)4Txe4y33C9zvNhMj Wrote:  Updated:

Code
from bs4 import BeautifulSoup
soup = BeautifulSoup(html)

for div in soup.find_all("div"):
 print("content: {}".format(div.text))

Thats not helping unfortunately.Thats why im asking, i just need div tags inside of this specific body tags.There a lot of div tags at outside of this body tags ..
(Apr 16, 2020 04:56 PM)SIM-1866423 Wrote:  Thats not helping unfortunately.Thats why im asking, i just need div tags inside of this specific body tags.There a lot of div tags at outside of this body tags ..

Could you elaborate?

You're trying to select all div tags in the body that have what feature?
(Apr 16, 2020 05:02 PM)4Txe4y33C9zvNhMj Wrote:  Could you elaborate?

You're trying to select all div tags in the body that have what feature?


No feature or anything table exact same in first post.
(Apr 16, 2020 05:05 PM)SIM-1866423 Wrote:  No feature or anything table exact same in first post.
You want to select the text from all the divs within the body element, correct? You're being so incredibly vague in every single post. Learn how to express your thoughts clearly.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(Apr 16, 2020 05:09 PM)Nachfolger Wrote:  You want to select the text from all the divs within the body element, correct? You're being so incredibly vague in every single post. Learn how to express your thoughts clearly.


[Image: KXoah7n.png]


I have literally 0 idea how this ambiguous but fine.
(Apr 16, 2020 05:21 PM)SIM-1866423 Wrote:  [Image: KXoah7n.png]


I have literally 0 idea how this ambiguous but fine.
You just need the text from each div? You said that outside of the body there are div tags, and you want to ignore them, but the screenshot you provided (in OP) has no divs outside of the body.

1. All divs in the screenshot are IN THE BODY
2. The code provided earlier pulls the text from inside each div

Again, I'm not seeing an issue.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by A +Feb 8, 2021 02:10 AM 8 206 Feb 8, 2021 02:10 AM
Last Post: vorticalbox
[Python] by SIM-574702Sep 11, 2017 01:45 AM 3 166 Sep 11, 2017 01:45 AM
Last Post: vorticalbox
[Python] by A +Mar 27, 2017 09:01 AM 10 205 Mar 27, 2017 09:01 AM
Last Post: Molino.