我有一个python脚本,它将一个url作为输入,并通过urllib打开url并解析一个网页。但是我得到了以下错误:
Traceback (most recent call last):
File "C:\Users\Arjun Gaur\Desktop\MyPython\arjurl.py", line 1, in <module>
import urllib.request, urllib.parse, urllib.error
File "C:\Users\Arjun Gaur\Desktop\MyPython\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a package
下面是文件arjsoup.py
import urllib.request
import urllib.parse
import urllib.error
import BeautifulSoup
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = print('Enter Link : ')
urlstr = urllib.request.urlopen(url,context=ctx).read()
soup = BeautifulSoup(urlstr,'html-parser')
tags = soup('a')
for tag in tags :
print(tag.get('href',None))