Advertisement
jackieradallhazik

parsing data

Mar 22nd, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import urllib2
  2. website = ''
  3. findstr = ''
  4. def urlfinder(html,string):
  5.     #condition
  6.     i = 0
  7.     if html.find(string) == -1:
  8.         print 'Web site khong co muc "' + string + ' nay'
  9.         return 0
  10.     if (html.find(string) != -1) or (html.find(string) != 0):  
  11.         while i >= 0:
  12.             if html[html.find(string)+len(string)+i] == '<' and html[html.find(string)+len(string)+i+1] == '/':
  13.                 return html[html.find(string)+len(string)+1:html.find(string)+len(string)+i]
  14.                 break
  15.             i = i + 1
  16. temp = urllib2.urlopen(website)
  17. data = temp.read()
  18. datastr= urlfinder(data,findstr)
  19. print datastr[1:len(datastr)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement