Creado clase de Exploring Task. Creado modulo de scraping utils
This commit is contained in:
parent
b1b7de13f8
commit
c0b398b9c6
13 changed files with 258 additions and 14 deletions
Binary file not shown.
BIN
core/__pycache__/scrapping_utils.cpython-36.pyc
Normal file
BIN
core/__pycache__/scrapping_utils.cpython-36.pyc
Normal file
Binary file not shown.
36
core/scrapping_utils.py
Normal file
36
core/scrapping_utils.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import requests
|
||||
|
||||
|
||||
class UrlAttack():
|
||||
|
||||
headers = {'Upgrade-Insecure-Requests': "1",
|
||||
'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
|
||||
'Accept-Encoding': "gzip, deflate, br",
|
||||
'Accept-Language': "en-US,en;q=0.9",
|
||||
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67.0.3396.99 Safari/537.36'}
|
||||
|
||||
timeout = 20
|
||||
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
self.success = None
|
||||
self.has_been_attacked = False
|
||||
|
||||
def attack(self):
|
||||
self.has_been_attacked = True
|
||||
try:
|
||||
self.response = requests.get(self.url, headers = headers,
|
||||
timeout = timeout)
|
||||
if self.response.ok:
|
||||
self.success = True
|
||||
except Exception:
|
||||
self.success = False
|
||||
|
||||
def get_response(self):
|
||||
if self.success:
|
||||
return self.response
|
||||
|
||||
def get_text(self):
|
||||
if self.success:
|
||||
return self.response.text()
|
||||
Loading…
Add table
Add a link
Reference in a new issue