TheEyesHaveIt
TheEyesHaveIt

Reputation: 1021

BeautifulSoup error: Invalid character in identifier

I am using bs4 (beautifulsoup) in python 3.2, and this is my code:

from urllib import urlopen
from bs4 import bs4
import re

webpage = urlopen(‘http://www.azlyrics.com/lyrics/kanyewest/workoutplan.html’).read()

It gives:

    webpage = urlopen(‘http://www.azlyrics.com/lyrics/kanyewest/workoutplan.html’).read()
                            ^
SyntaxError: invalid character in identifier

How can I fix this?

Upvotes: 0

Views: 4864

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121406

You are not using ASCII quote characters; is not a legal quote in Python syntax.

Use a text editor to edit your Python source code, not one that replaces plain ASCII quotes with fancy quotes.

Use ' or ":

webpage = urlopen('http://www.azlyrics.com/lyrics/kanyewest/workoutplan.html').read()
webpage = urlopen("http://www.azlyrics.com/lyrics/kanyewest/workoutplan.html").read()

See String and Bytes literals for the exhaustive list of options.

Upvotes: 5

Related Questions