Difference between revisions of "Python: Read URL"

From OnnoWiki
Jump to navigation Jump to search
(Created page with " pip install requests Script import requests link = "http://www.somesite.com/details.pl?urn=2344" f = requests.get(link) print(f.text) ==Pranala Menarik== * Pyt...")
 
Line 5: Line 5:
  
 
  import requests
 
  import requests
 +
from BeautifulSoup import BeautifulSoup
 
   
 
   
 
  link = "http://www.somesite.com/details.pl?urn=2344"
 
  link = "http://www.somesite.com/details.pl?urn=2344"
 
  f = requests.get(link)
 
  f = requests.get(link)
 
  print(f.text)
 
  print(f.text)
 +
 +
soup = BeautifulSoup(f)
 +
all_text = ''.join(soup.findAll(text=True))
 +
print(all_text)
  
  

Revision as of 08:28, 29 April 2019

pip install requests


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