Skip to content

Commit 5ab7c2e

Browse files
committed
Update
1 parent 4d05182 commit 5ab7c2e

File tree

7 files changed

+140
-81
lines changed

7 files changed

+140
-81
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "/usr/bin/python3"
3+
}

instapic.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,32 @@
11
#!/usr/bin/env python
22

3-
## Instagram Post Image Downloader
4-
## Install Python pip Modules
5-
6-
# Python2 (pip)
7-
## pip install wget
8-
## pip install beautifulsoup4
9-
## pip install lxml
3+
## Install Python3 pip Modules
104

115
# Python3 (pip)
126
## pip3 install wget
137
## pip3 install beautifulsoup4
148
## pip3 install lxml
159

10+
from urllib.request import urlopen
1611
from bs4 import BeautifulSoup
1712
import wget
1813

19-
try: #python3
20-
from urllib.request import urlopen
21-
except: #python2
22-
from urllib2 import urlopen
23-
input = raw_input
24-
2514
## User input
26-
url = input("\033[1;32mEnter a Instagram Post URL : \033[1;m")
27-
28-
insta_post = urlopen(url)
29-
bs = BeautifulSoup(insta_post , "lxml")
30-
31-
## Find Insta Post Image URL
32-
metatag = bs.find("meta", {"property": "og:image"})
15+
URL = input("\033[1;32mEnter a Instagram Post URL : \033[1;m")
3316

34-
if metatag is not None:
17+
INSTA_POST = urlopen(URL)
18+
BS = BeautifulSoup(INSTA_POST, "lxml")
3519

36-
print (metatag["content"])
37-
print ("\n")
20+
## Find Insta Post Image
21+
METATAG = BS.find("meta", {"property": "og:image"})
3822

39-
print ("Image Started Downloading.......")
23+
if METATAG is not None:
4024

41-
## Download Image via Wget
42-
filename = wget.download(metatag["content"])
43-
print ("\n")
25+
print(METATAG["content"])
26+
print("Image Started Downloading.......")
4427

45-
print ("Done")
46-
print ("\n")
28+
## Download Image via Wget Method
29+
FILENAME = wget.download(METATAG["content"])
4730

4831
else:
49-
print ("Error")
32+
print("Error")

test/instapic.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
3+
## Instagram Post Image Downloader
4+
## Install Python pip Modules
5+
6+
# Python2 (pip)
7+
## pip install wget
8+
## pip install beautifulsoup4
9+
## pip install lxml
10+
11+
# Python3 (pip)
12+
## pip3 install wget
13+
## pip3 install beautifulsoup4
14+
## pip3 install lxml
15+
16+
from bs4 import BeautifulSoup
17+
import wget
18+
19+
try: #python3
20+
from urllib.request import urlopen
21+
except: #python2
22+
from urllib2 import urlopen
23+
input = raw_input
24+
25+
## User input
26+
url = input("\033[1;32mEnter a Instagram Post URL : \033[1;m")
27+
28+
insta_post = urlopen(url)
29+
bs = BeautifulSoup(insta_post , "lxml")
30+
31+
## Find Insta Post Image URL
32+
metatag = bs.find("meta", {"property": "og:image"})
33+
34+
if metatag is not None:
35+
36+
print (metatag["content"])
37+
print ("\n")
38+
39+
print ("Image Started Downloading.......")
40+
41+
## Download Image via Wget
42+
filename = wget.download(metatag["content"])
43+
print ("\n")
44+
45+
print ("Done")
46+
print ("\n")
47+
48+
else:
49+
print ("Error")
File renamed without changes.

test/weblink.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
#!/usr/bin/env python
22

3-
from BeautifulSoup import BeautifulSoup
4-
#import urllib2
5-
import cfscrape
6-
import re
7-
8-
#html_page = urllib2.urlopen("https://example.com")
9-
10-
# Get the text at the set URL
11-
scraper = cfscrape.create_scraper()
3+
## Scrape Internal Links & External Links
4+
## Install Python pip Modules
5+
6+
# Python2 (pip)
7+
## pip install cfscrape
8+
## pip install beautifulsoup4
9+
## pip install lxml
10+
11+
# Python3 (pip)
12+
## pip3 install cfscrape
13+
## pip3 install beautifulsoup4
14+
## pip3 install lxml
15+
16+
#from bs4 import BeautifulSoup
17+
#import cfscrape
18+
#import re
19+
20+
import sys
1221

13-
url = "https://example.com"
22+
VER = 2
23+
24+
try:
25+
if sys.version_info >= (3,0):
26+
VER = 3
27+
from bs4 import BeautifulSoup
28+
import cfscrape
29+
import re
30+
else:
31+
input = raw_input
32+
from bs4 import BeautifulSoup
33+
import cfscrape
34+
import re
35+
except:
36+
pass
37+
38+
39+
## User input
40+
url = input("\033[1;32mEnter a URL : \033[1;m")
41+
42+
scraper = cfscrape.create_scraper()
1443
cfurl = scraper.get(url).content
15-
soup = BeautifulSoup(cfurl)
44+
soup = BeautifulSoup(cfurl, "lxml")
1645
for link in soup.findAll('a', attrs={'href': re.compile("^(http|https)://")}):
1746

18-
## Print Output
19-
print link.get('href')
47+
urls = link.get("href")
48+
print (urls)
49+

test/weblinks.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
from BeautifulSoup import BeautifulSoup
4+
#import urllib2
5+
import cfscrape
6+
import re
7+
8+
#html_page = urllib2.urlopen("https://example.com")
9+
10+
# Get the text at the set URL
11+
scraper = cfscrape.create_scraper()
12+
13+
url = "https://example.com"
14+
cfurl = scraper.get(url).content
15+
soup = BeautifulSoup(cfurl)
16+
for link in soup.findAll('a', attrs={'href': re.compile("^(http|https)://")}):
17+
18+
## Print Output
19+
print link.get('href')

weblink.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,24 @@
11
#!/usr/bin/env python
22

3-
## Scrape Internal Links & External Links
4-
## Install Python pip Modules
3+
## Install Python3 pip Modules
54

6-
# Python2 (pip)
7-
## pip install cfscrape
8-
## pip install beautifulsoup4
9-
## pip install lxml
10-
11-
# Python3 (pip)
5+
## Python3 (pip)
126
## pip3 install cfscrape
137
## pip3 install beautifulsoup4
148
## pip3 install lxml
159

16-
#from bs4 import BeautifulSoup
17-
#import cfscrape
18-
#import re
19-
20-
import sys
21-
22-
VER = 2
23-
24-
try:
25-
if sys.version_info >= (3,0):
26-
VER = 3
27-
from bs4 import BeautifulSoup
28-
import cfscrape
29-
import re
30-
else:
31-
input = raw_input
32-
from bs4 import BeautifulSoup
33-
import cfscrape
34-
import re
35-
except:
36-
pass
37-
10+
import re
11+
import cfscrape
12+
from bs4 import BeautifulSoup
3813

3914
## User input
40-
url = input("\033[1;32mEnter a URL : \033[1;m")
15+
URL = input("\033[1;32m Enter a URL : \033[1;m")
4116

42-
scraper = cfscrape.create_scraper()
43-
cfurl = scraper.get(url).content
44-
soup = BeautifulSoup(cfurl, "lxml")
45-
for link in soup.findAll('a', attrs={'href': re.compile("^(http|https)://")}):
17+
SCRAPER = cfscrape.create_scraper()
18+
CFURL = SCRAPER.get(URL).content
19+
SOUP = BeautifulSoup(CFURL, "lxml") #html.parser
20+
for link in SOUP.findAll('a', attrs={'href': re.compile("^(http|https)://")}):
4621

47-
urls = link.get("href")
48-
print (urls)
49-
22+
urls = link.get("href")
23+
#print(urls)
24+
print('\033[1;33m %s \033[1;m' %urls)

0 commit comments

Comments
 (0)