Grab all of the href links from a Page

Posted by Jessica Tue, 06 Feb 2007 17:49:00 GMT

Use Rubyful Soup to get all of the hyperlinks on a page…

soup = BeautifulSoup.new(page_content)
result = soup.find_all('a')
result.each { |tag| 
  urls[i] = tag['href']
  if urls[i].to_s.slice(0,1) != 'h' then
          #add first part of url to href link if link is internal
          urls[i] = home + urls[i]
  end
  i = i + 1
}

PHP and Hyperlinks

Posted by closetmaster Sat, 13 Aug 2005 04:03:00 GMT

I have moved into the 21st century and finally made my Extracurriculars page database driven. One interesting hang up that I ran into was including hyperlinks in the text that I saved in the database. The solution to getting the hyperlinks to print out was to take the quotes from the a href tags. So, a href= “http://www.google.com” became a href= http://www.google.com

Yes, this is incredibly simple, but if I don’t right down somewhere that I found this piece of information down, I won’t be able to remember it the next time I need it. I’ve always had a hard time remembering syntax.


designed by jowensbysandifer