8000 Add files via upload · realpython/python-scripts@3720e67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3720e67

Browse files
authored
Add files via upload
1 parent 5168018 commit 3720e67

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
4+
# get url
5+
6+
url = input('Enter a URL (include `http://`): ')
7+
response = requests.get(url)
8+
html = response.text
9+
soup = BeautifulSoup(html,"html.parser")
10+
print(html)
11+
12+
links = []
13+
for i in soup.find_all("a",href=True):
14+
links.append(1)
15+
print("link is found: ", i)
16+
# connect to the url
17+
website = requests.get(url)
18+
19+
# read html
20+
html = website.text
21+
22+
# use re.findall to grab all the links
23+
links = re.findall('"((http|ftp)s?://.*?)"', html)
24+
emails = re.findall('([\w\.,]+@[\w\.,]+\.\w+)', html)
25+
26+
27+
# print the number of links in the list
28+
print("\nFound {} links".format(len(links)))
29+
for email in emails:
30+
print(email)

0 commit comments

Comments
 (0)
0