Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yaml
- import requests
- from urllib import parse
- from bs4 import BeautifulSoup
- with open('YAML.yaml', 'r') as f:
- doc = yaml.safe_load(f)
- scrp_list = []
- page = requests.get(doc[1]['url'])
- try:
- page.status_code == 200
- except Exception as exc:
- print("There was an error: %s " % exc)
- SOUP = BeautifulSoup(page.text, 'lxml')
- post_mark = (doc[0]['post']['tag'])
- post_mark2 =(doc[1]['post']['tag'])
- def get_data(scope, tag, clss=None):
- for data in scope.find
- if clss:
- for class_data in data.find_all(tag, attrs={'class': clss}):
- class_data.getText()
- else:
- return data.getText()
- get_data(post_mark2, doc[1]['post']['title']['tag'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement