Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import yaml
  2. import requests
  3. from urllib import parse
  4. from bs4 import BeautifulSoup
  5.  
  6.  
  7. with open('YAML.yaml', 'r') as f:
  8. doc = yaml.safe_load(f)
  9.  
  10.  
  11. scrp_list = []
  12.  
  13. page = requests.get(doc[1]['url'])
  14. try:
  15. page.status_code == 200
  16. except Exception as exc:
  17. print("There was an error: %s " % exc)
  18.  
  19. SOUP = BeautifulSoup(page.text, 'lxml')
  20. post_mark = (doc[0]['post']['tag'])
  21. post_mark2 =(doc[1]['post']['tag'])
  22.  
  23.  
  24. def get_data(scope, tag, clss=None):
  25. for data in scope.find
  26. if clss:
  27. for class_data in data.find_all(tag, attrs={'class': clss}):
  28. class_data.getText()
  29. else:
  30. return data.getText()
  31.  
  32.  
  33. get_data(post_mark2, doc[1]['post']['title']['tag'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement