我正在运行一个批处理文件,该文件通过命令提示符运行python代码。但是,在运行代码时,会出现以下错误:
from html_table_parser import HTMLTableParser
ModuleNotFoundError: No module named 'html_table_parser'
然而,当我在Jupyter笔记本上运行我的代码时,它的效果很好。是因为没有正确下载吗。我的python.exe在Anaconda中找到
我的代码如下
import urllib.request
from pprint import pprint
from html_table_parser import HTMLTableParser
import datetime
# pretty-print python data structures
from pprint import pprint
# for parsing all the tables present on the website
# for converting the parsed data in a
# pandas dataframe
import pandas as pd
from bs4 import BeautifulSoup
# Opens a website and read its
# binary contents (HTTP Response Body)
def url_get_contents(url):
# Opens a website and read its
# binary contents (HTTP Response Body)
#making request to the website
req = urllib.request.Request(url=url)
f = urllib.request.urlopen(req)
#reading contents of the website
return f.read()
xhtml = url_get_contents("https://en.wikipedia.org/wiki/Searching").decode('utf-8')
# Defining the HTMLTableParser object
p = HTMLTableParser()
content = urllib.request.urlopen("https://en.wikipedia.org/wiki/Searching")
read_content = content.read()
目前没有回答
相关问题 更多 >
编程相关推荐