Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- class Noticias(object):
- def __init__(self, url, headers, tags, news, proxxy,cookie):
- self.url = url
- self.tags = tags
- self.headers = headers
- self.news = news
- self.proxxy = proxxy
- self.cookie = cookie
- def getUrl(self):
- return self.url
- def getHeaders(self):
- return self.headers
- def getTags(self):
- return self.tags
- def getNews(self):
- return self.news
- def getProxxy(self):
- return self.proxxy
- def getCookie(self):
- return self.cookie
- url = "https://canaltech.com.br/"
- proxies = {
- "http": "http://51.79.84.78:8000",
- "http": "https://391.134.180.0:3128",
- }
- headers = {
- "authority": "canaltech.com.br",
- "method": "GET",
- "path": "/mais-lidas/",
- "scheme": "https",
- "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
- "accept-encoding": "gzip, deflate, br",
- "accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
- "cookie":" _ga=GA1.3.2109960112.1574971634; OB-USER-TOKEN=c5672179-30c2-4bc7-8315-39c4349025a4; tt.u=830A000A68BD525D8C588AA902BF852B; _ducp=eyJfZHVjcCI6ImY2YTZiOGY4LWY5MTktNDM2Mi04N2Y5LTgxOWJlOTc3YzFhYSIsIl9kdWNwcHQiOiIifQ==; modal-extensao-hide=true; bannertop=premioct2019; __cfduid=d452d6db4354a558bd5442eeadcc147ba1578526069; _gid=GA1.3.761870493.1578925249; tt.nprf=64,68,81,88,24,20,44; _ducprs=eyJMYXN0Q29uc3VsdCI6IjIwMjAtMDEtMTMgMTc6Mjk6NDQiLCJQZXJzb25hQWxpYXMiOm51bGx9; tt_c_vmt=1578946024; tt_c_c=direct; tt_c_s=direct; tt_c_m=direct; _ttuu.s=1578946143403; _gat=1; modal-extensao-pv=43; timelineViewed=343555%2C343555%2C343427%2C343458%2C343427%2C343458%2C54070%2Cfalse; _gat_uolMain=1",
- "sec-fetch-mode": "navigate",
- "sec-fetch-site": "none",
- "sec-fetch-user": "?1",
- "upgrade-insecure-requests": "1",
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36"}
- cookie = {
- "OB-USER-TOKEN":"c5672179-30c2-4bc7-8315-39c4349025a4"
- }
- tags = 'teste tags'
- news = "novo teste de news"
- search = Noticias(url, tags, headers, news, proxxy,cookie)
- try:
- response = requests.post(url, headers=search.getProxxy(),cookies=search.getCookie())
- if response.status_code == 200:
- soup = BeautifulSoup(response.text,'html.parser')
- print(soup)
- else:
- pass
- except (requests.exceptions.HTTPError, requests.exceptions.RequestException, requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
- print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement