I'm trying to extract a text from the forum website, it works good but there's a problem with split the text
s = "Username[^\"]+<br"
r = requests.get("https://example.com/threads/73956/page2", headers=headers, cookies=cookies)
soup = BeautifulSoup(r.content, "html.parser")
comments = soup.find_all('div',{'class':'wwCommentBody'})
for div in comments:
bq = div.find('blockquote',{'class':'postcontent restore'})
result = re.findall(s, r.text)
print (result)
It prints like this:
['Username: Marvel<br']
How can I make it extracts to the last letter of the username value Marvel
without the <br
and ['']
?
<div class="wwCommentBody">
<blockquote class="postcontent restore " style="padding: 10px;">Username:
leetibrahim<br>
Number: 2
</blockquote>
</div>
` like this: `print(result[0].replace("
", ""))`. – Ezra Jun 28 '21 at 17:27