Advertisement
Guest User

Untitled

a guest
May 24th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import re
  2. from urllib.request import urlopen
  3.  
  4.  
  5. url = 'https://www.amazon.com.au/gp/rss/bestsellers/electronics'
  6.  
  7. html_code = urlopen(url)
  8.  
  9. code = html_code.read().decode('UTF-8')
  10.  
  11. html_code.close()
  12.  
  13. variables = re.findall('\<\div class\=\"\col search_price responsive_secondrow\"\>\(.*?)\<\/\div\>\'',code)
  14.  
  15.  
  16. print(variables)
  17.  
  18. """
  19. start_tag = '<title><![CDATA['
  20. end_tag = ']]></title>'
  21. starting_position = code.find(start_tag)
  22. end_position = code.find(end_tag)
  23. while starting_position != -1 and end_position != -1:
  24. print(code[starting_position + len(start_tag): end_position])
  25. starting_position = code.find(start_tag, end_position)
  26. end_position = code.find(end_tag, starting_position)
  27. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement