How to download Douban girl pictures by python crawler
This article mainly explains "python crawler how to download Douban girl picture", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "python crawler how to download Douban girl picture"!
The code is as follows:
Import requestsimport reimport timefrom bs4 import BeautifulSoup
Cat = '2'img =' http://www.dbmeinv.com/dbgroup/show.htm?cid='+ catend ='/ dbgroup/show.htm?cid='+ cat +'& pager_offset=100'urls = [] def getURLs (mainURL): time.sleep (1) headers = {'User-Agent':' Mozilla/5.0 (Macintosh) Intel Mac OS X 10 / 11 / 2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36'} html = requests.get (mainURL). Text soup = BeautifulSoup (html, 'html.parser') picURL = re.findall ('