Python: Problems finding string in website source code

Posted by j00niner on Stack Overflow See other posts from Stack Overflow or by j00niner
Published on 2010-05-06T07:01:09Z Indexed on 2010/05/06 7:18 UTC
Read the original article Hit count: 129

Filed under:

I open a website with urlopen. I then put the website sourcecode into a variable like so

source = website.read()

When I just print the source it comes out formatted correctly, however when I try to iterate through each line each character is it's own line.

for example

when I just print it looks like this

<HTML> title</html>

When I do this

for line in source:
      print line

it looks like this

<
H
T
M
L
... etc

I need to find a string that starts with "var" and then print that entire line.

© Stack Overflow or respective owner

Related posts about python