Skip to content

Instantly share code, notes, and snippets.

@manashmandal
Created July 29, 2016 14:33
Show Gist options
  • Save manashmandal/daed7cd8bd59bf29ffe417c5b5005b6a to your computer and use it in GitHub Desktop.
Save manashmandal/daed7cd8bd59bf29ffe417c5b5005b6a to your computer and use it in GitHub Desktop.
from selenium import webdriver
from bs4 import BeautifulSoup
news_link = 'http://www.dhakatribune.com/tags/bangladesh%20garments'
news_class = 'entry-title'
class GetNewsLinks():
def __init__(self):
self.chrome = webdriver.Chrome()
self.chrome.get(news_link)
self.current_url = ''
def getLinksFromCurrentPage(self):
self.current_url = self.chrome.current_url
links = self.chrome.find_elements_by_class_name(news_class)
for link in links:
print link.get_attribute('href')
def __del__(self):
self.chrome.close()
if __name__ == '__main__':
getNewsLink = GetNewsLinks()
getNewsLink.getLinksFromCurrentPage()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment