Advertisement
Guest User

Untitled

a guest
May 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import re
  2. from urllib.request import urlopen
  3.  
  4.  
  5. url = 'http://www.tigerdirect.com/sectors/category/deal-of-the-day-rss.asp'
  6.  
  7. html_code = urlopen(url)
  8.  
  9. code = html_code.read().decode('UTF-8')
  10.  
  11. html_code.close()
  12.  
  13. productname = re.findall("\<title\>\<\!\[CDATA\[(.*?)\]\]\>\<\/title\>", code)
  14. productprice = re.findall('List Price: (.*?)<br /><strong>', code)
  15.  
  16. print(productname)
  17. print(productprice)
  18.  
  19. """
  20. start_tag = '<title><![CDATA['
  21. end_tag = ']]></title>'
  22. starting_position = code.find(start_tag)
  23. end_position = code.find(end_tag)
  24. while starting_position != -1 and end_position != -1:
  25. print(code[starting_position + len(start_tag): end_position])
  26. starting_position = code.find(start_tag, end_position)
  27. end_position = code.find(end_tag, starting_position)
  28. """
  29.  
  30. costs=re.findall("\<\!\[CDATA\[\€\[\d]+\.\[\d]+]]>", code)
  31. print(costs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement