Skip to content

Instantly share code, notes, and snippets.

@mr-yoo
Created December 2, 2017 10:34
Show Gist options
  • Save mr-yoo/2871e1d3e8b07652d07df6b9912d4432 to your computer and use it in GitHub Desktop.
Save mr-yoo/2871e1d3e8b07652d07df6b9912d4432 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
def get_latest_press(code) :
# Get HTML codes
url = "https://www.bloomberg.com/quote/" + code
response = requests.get(url).text
# Get the first element of press releases
soup = BeautifulSoup(response, "html5lib")
# select = "#root > div > div > section.quotePageMainContent.page-modules > div.module.newsAndPressReleasesContainer__e3243a6f > div.newsAndPressReleases__d7294973 > div.pressReleasesContainer__c79992bc.selected > div > div > article:nth-of-type(1) > a > div > div.headline__eb73356e"
select = "div.pressReleasesContainer__c79992bc.selected > div > div > article:nth-of-type(1) > a > div > div.headline__eb73356e"
return soup.select(select)[0].text
code = "600019:CH"
press = get_latest_press(code)
print (press)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment