Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
# To run this, download the BeautifulSoup zip file # http://www.py4e.com/code3/bs4.zip # or pip install beautifulsoup4 to ensure you have the latest version # and unzip it in the same directory as this file import urllib.request, urllib.parse, urllib.error from bs4 import BeautifulSoup import ssl # defauts to certicate verification and most secure protocol (now TLS) # Ignore SSL/TLS certificate errors ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE url = input('Enter - ') html = urllib.request.urlopen(url, context=ctx).read() soup = BeautifulSoup(html, 'html.parser') #Follow link at below position count=17 #Follow link this many times times=6 # Retrieve all of the anchor tags tags = soup('a') lst = list() for tag in tags: #print(tag.get('href', None)) lst.append(tag.get('href', None)) print(lst[count]) for i in range(times): url = lst[count] html = urllib.request.urlopen(url, context=ctx).read() soup = BeautifulSoup(html, 'html.parser') # Retrieve all of the anchor tags tags = soup('a') lst = list() for tag in tags: #print(tag.get('href', None)) lst.append(tag.get('href', None)) print(lst[count])
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)