我尝试重新安装requests
模块,但没有帮助:
(C:\ Users \ user \ Anaconda3)C:\Users\user>Desktop\receipt.py
Traceback (most recent call last):
File "C:\Users\user\Desktop\receipt.py", line 8, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
(C:\ Users \ user \ Anaconda3)C:\Users\user>pip uninstall requests
Uninstalling requests-2.18.4:
Would remove:
c:\users\user\anaconda3\lib\site-packages\requests-2.18.4.dist-info\*
c:\users\user\anaconda3\lib\site-packages\requests\*
Proceed (y/n)? \y
Your response ('\\y') was not one of the expected responses: y, n
Proceed (y/n)? y
Successfully uninstalled requests-2.18.4
(C:\ Users \ user \ Anaconda3)C:\Users\user>pip install requests
Collecting requests
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\anaconda3\lib\site-packages (from requests) (2017.7.27.1)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\users\user\anaconda3\lib\site-packages (from requests) (1.22)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\user\anaconda3\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in c:\users\user\anaconda3\lib\site-packages (from requests) (2.6)
Installing collected packages: requests
Successfully installed requests-2.18.4
(C:\ Users \ user \ Anaconda3)C:\Users\user>Desktop\receipt.py
Traceback (most recent call last):
File "C:\Users\user\Desktop\receipt.py", line 8, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
receipt.py
import requests
from bs4 import BeautifulSoup
url='http://invoice.etax.nat.gov.tw/'
html=requests.get(url)
html.encoding='UTF-8'
sp=BeautifulSoup(html.text,'html.parser')
title1=sp.select('#area1')
title2=title1[0].find_all('h2')
print(title2[1].text,"Winning Numbers\n")
prize1=sp.find_all('span',{'id':'newFirstPrize'})
print("number:",prize1[0].text)
prize2=sp.find_all("span",{'class':'t18Red'})
print("\n Special Prize:\n",prize2[0].text)
prize3=sp.find_all("span",{'class':'t18Red'})
print("\n Grand Prize:\n",prize3[1].text)
prize4=sp.find_all('span',{'id':'newAddSixPrize'})
print("\n Additional Sixth Prize:\n",prize4[0].text)
input("Press <enter>")