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.
CodePudding user response:
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()