I use urllib to get an html string from a website and must put each word in an html document in a list.
Here is the code I have. I keep getting the error. I also copied the error below.
import urllib.request url = input("Please enter a URL: ") z=urllib.request.urlopen(url) z=str(z.read()) removeSpecialChars = str.replace(" !@ #$%^&*()[]{};:,./<>?\|`~-=_+", " ") words = removeSpecialChars.split() print ("Words list: ", words[0:20])
Here is the error.
Please enter a URL: http://simleyfootball.com Traceback (most recent call last): File "C:\Users\jeremy.KLUG\My Documents\LiClipse Workspace\Python Project 2\Module2.py", line 7, in <module> removeSpecialChars = str.replace(" !@ #$%^&*()[]{};:,./<>?\|`~-=_+", " ") TypeError: replace() takes at least 2 arguments (1 given)
python string list replace urllib
user2363217
source share