'How to get text from specific url?
I was wondering if there's any way to get text from certain url using python.
For example, from this one https://www.ixbt.com/news/2022/04/20/160-radeon-rx-6400.html
Thank you in advance.
Solution 1:[1]
You can do web scraping in python using BeautifulSoup:
from urllib.request import urlopen
from bs4 import BeautifulSoup
url = "https://www.ixbt.com/news/2022/04/20/160-radeon-rx-6400.html"
html = urlopen(url).read()
soup = BeautifulSoup(html, features="html.parser")
text = soup.get_text()
After that you could save the extracted text into a text file:
text_file = open("webscrap.txt", "w", encoding="utf-8")
text_file.write(text)
text_file.close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
