Posted By

tionazo on 12/26/14


Tagged

regex python web urllib2


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

pcpc


Get all links from a website


 / Published in: Python
 

URL: http://www.pythonforbeginners.com/code/regular-expression-re-findall

Get all links from a website from: http://www.pythonforbeginners.com/code/regular-expression-re-findall

  1. import urllib2
  2. import re
  3.  
  4. #connect to a URL
  5. website = urllib2.urlopen(url)
  6.  
  7. #read html code
  8. html = website.read()
  9.  
  10. #use re.findall to get all the links
  11. links = re.findall('"((http|ftp)s?://.*?)"', html)
  12.  
  13. print links

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: John132 on May 18, 2018

In college I and my friend from

Posted By: JulOz on March 23, 2019

You should go here if you want to know how to write a dissertation.

Posted By: jasonry on August 27, 2019

You should go here if you want more knowledge about [url=https://www.allassignmenthelp.co.uk/]Assignment help[/url] or Visit us :-https://www.allassignmenthelp.co.uk/

Posted By: jasonry on August 27, 2019

Assignment help who have been providing help to the students of various renowned colleges and universities of Java assignment help step-by-step.

Posted By: essaysnassignment on October 12, 2019

Hello,this is an awesome post thanks for sharing.It is relay enjoy to read this post. cheap dissertation writing servicesdissertation service ukucas personal statement exampleshow to write personal statementpostgraduate personal statementmasters personal statementwriting a personal statementhow to write a personal statementhow to write a personal statementhow to write a personal statementdissertation servicedissertation writing services ukdissertation writingwriting a dissertationhow to write a dissertation

You need to login to post a comment.