Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wikipedia转储xml文件在python中转换为文本_Python - Fatal编程技术网

Wikipedia转储xml文件在python中转换为文本

Wikipedia转储xml文件在python中转换为文本,python,Python,如何将wikimeadia转储xml文件转换为python中的文本。python中有任何包吗?不确定您有什么转储文件,您试图从文章中转换web内容,读取元素,并使用python写入文件 使用请求和bs4对象更好地使用网站刮取: #Getting data from website - scrape import requests, bs4 #Getting HTML from the wikipedia page url = "https://en.wikipedia.org/wiki/Ei

如何将wikimeadia转储xml文件转换为python中的文本。python中有任何包吗?

不确定您有什么转储文件,您试图从文章中转换web内容,读取元素,并使用python写入文件

使用请求和bs4对象更好地使用网站刮取:

#Getting data from website - scrape 
import requests, bs4

#Getting HTML from the wikipedia page
url = "https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors"
req = requests.get(url)

#Create a bs4 object
soup = bs4.BeautifulSoup(req.text, "html5lib")

element = soup.select('.mwe-math-element')

print(element)
#You can save the required content to a file by manipulating the content in element list

我从链接中找到了XML文件: