Skip to content

Commit

Permalink
Scraping all the links in a web page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan7390 authored Nov 10, 2019
1 parent f425068 commit 90f45e9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions links_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests
import bs4
link_list=[]
res = requests.get('https://www.apple.com/')
soup = bs4.BeautifulSoup(res.text, 'lxml')

for link in soup.find_all('a', href=True):
'''link_list.append(link)
# if link[0]=='#':
# link_list.remove(link)
if link[0]=='/':
link_list.remove(link)
link_list
'''
# if link['href']!="#":
# print(link["href"])
if link['href'][0]=='#':
pass
elif link['href'][0]=='/':
pass
else:
print(link['href'])

0 comments on commit 90f45e9

Please sign in to comment.