Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, bs4, re
- url = r'http://www.bing.com/images/search?q=scarlett+johansson&qft=%2Bfilterui%3Aimagesize-large'
- r = requests.get(url)
- soup = bs4.BeautifulSoup(r.content)
- res = soup.findAll('div', {'class': 'dg_u'})
- for div in res:
- a_elem = div.find('a')
- m_attr = a_elem.get('m')
- if m_attr:
- dirty_url = m_attr.split('oi:')[-1]
- pattern = "http:.*.jpg"
- matches = re.findall(pattern, dirty_url)
- if matches:
- cleaned_url = matches[0]
- print cleaned_url
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement