Reputation: 2499
I am using code as below
import time
import mechanize
from bs4 import BeautifulSoup
import urllib2
import cookielib
cj = cookielib.CookieJar()
br = mechanize.Browser()
br.set_cookiejar(cj)
br.open("http://ipcamera.userlocal.jp/photos/latest?camera_id=123456")
br.select_form(nr=0)
br.form['login[camera_code]'] = '123456'
br.form['login[pass]'] = '7890'
br.submit()
soup = BeautifulSoup(br.response().read())
links = soup.find_all('img', src=True)
for link in links:
timestamp = time.asctime()
link = link["src"].split("src=")[-1]
print link
But I got error as below, how can I avoid these errors, or is that any eaisr way to scrape web page with password? thanks a lot.
C:\Program Files (x86)\Python27\lib\site-packages\bs4\__init__.py:181: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 21 of the file login.py. To get rid of this warning, change code that looks like this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser")
markup_type=markup_type))
Upvotes: 0
Views: 735
Reputation: 9081
This is not an error - just a mere warning. Since you did not specify the parser explicitly.
Modify this line -
soup = BeautifulSoup(br.response().read(),"html.parser")
And see if it works out. Answering from mobile so code is not formatted. Will do it once I access my pc in an hour :)
Upvotes: 1