Difference between revisions of "Python: Read URL"

From OnnoWiki
Jump to navigation Jump to search
Line 1: Line 1:
 
  pip install requests
 
  pip install requests
 
+
pip install BeautifulSoup
  
 
Script
 
Script

Revision as of 08:29, 29 April 2019

pip install requests
pip install BeautifulSoup

Script

import requests
from BeautifulSoup import BeautifulSoup

link = "http://www.somesite.com/details.pl?urn=2344"
f = requests.get(link)
print(f.text)
soup = BeautifulSoup(f)
all_text = .join(soup.findAll(text=True))
print(all_text)


Pranala Menarik