Advertisement
jackieradallhazik

get data in web

Mar 7th, 2015
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import urllib
  2. u = urllib.urlopen('http://learnprobyjack.pe.hu/')
  3. data = u.read()
  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. print urlfinder(data,'number')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement