-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Miguel Sanchez
authored and
Miguel Sanchez
committed
Dec 4, 2022
1 parent
592bd2a
commit c662d4a
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from urllib.parse import urljoin | ||
import requests | ||
import re | ||
|
||
|
||
user_agent_ = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" | ||
header = {"User-Agent": user_agent_} | ||
|
||
def scan(url: str) -> str: | ||
s = requests.Session() | ||
r = s.get(url, verify=False, headers=header) | ||
content = r.content | ||
links = re.findall('(?:href=")(.*?)"', content.decode('utf-8')) | ||
link_list = [] | ||
for page_links in links: | ||
page_links = urljoin(url, page_links) | ||
link_list.append(page_links + "\n") | ||
with open("output/spider.txt", "w") as f: | ||
f.writelines(link_list) |