__init__.py 548 B

123456789101112131415161718192021222324252627282930
  1. import requests
  2. import xml.etree.ElementTree as ET
  3. class Bing:
  4. def __init__(self):
  5. self.url = 'https://www.bing.com/search'
  6. '''
  7. def search_hosts(self, hosts):
  8. for host in hosts:
  9. parse(search(host['ip']))
  10. def search(self, ip,):
  11. r = requests.get(self.url, params={'q': 'ip:' + ip, 'format': 'rss', 'first': first});
  12. tree = ET.fromstring(r.content)
  13. return tree
  14. def parse(self, tree):
  15. count = 0
  16. for i in tree[0]:
  17. if i.tag == 'item':
  18. count += 1
  19. print(i[1].text)
  20. if count == 10:
  21. return 1
  22. else:
  23. return 0
  24. '''