Here is my input:
..........
-
You can also make the data coming from your input a str object, like this:
url = "http://www.google.com"
req = request.Request(url)
response = request.urlopen(req)
page = str(response.read()) # make it a str object
print(page[page.find('id='):]) # now you don't need a b in front of your string
讨论(0)
-
You can't use bytes.find()
to find a str
object inside a bytes
object(since they're different types, a str
can't be inside bytes
).
You can, however, look for a bytes object inside it. This should work:
start_link = input.find(b' <p class="js-tweet-text tweet-text" ')
Btw, you should be using an html parser if you're parsing html.
讨论(0)