8000 new script · realpython/python-scripts@f467a62 · GitHub
[go: up one dir, main page]

Skip to content

Commit f467a62

Browse files
committed
new script
1 parent a6e299f commit f467a62

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
File renamed without changes.

02_find_all_links.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import urllib2
2+
import re
3+
4+
# get url
5+
url =raw_input('Enter a URL (include `http://`): ')
6+
7+
# connect to the url
8+
website = urllib2.urlopen(url)
9+
10+
# read html
11+
html = website.read()
12+
13+
# use re.findall to grab all the links
14+
links = re.findall('"((http|ftp)s?://.*?)"', html)
15+
16+
# output links
17+
for link in links:
18+
print link[0]

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
## Just another repo of Python scripts
22

3-
1. **remove_all_pyc.md**: remove all *.pyc* files from a git repo
3+
1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo
4+
2. **02_find_all_links.py**: get all links from a webpage

0 commit comments

Comments
 (0)
0