get_hypertext
- pyrcs.parser.get_hypertext(hypertext_tag, hyperlink_tag_name='a', md_style=True)
Get text that is with a hyperlink.
- Parameters
hypertext_tag (bs4.element.Tag or bs4.element.PageElement) – tag of hypertext (i.e. text that is with a hyperlink)
hyperlink_tag_name (str) –
md_style (bool) – whether to return the obtained hypertext in markdown style, defaults to
True
- Returns
hypertext
- Return type
str
Examples:
>>> from pyrcs.parser import get_hypertext >>> from pyrcs.line_data import Electrification >>> import bs4 >>> import requests >>> elec = Electrification() >>> url = elec.catalogue[elec.KEY_TO_INDEPENDENT_LINES] >>> source = requests.get(url) >>> soup = bs4.BeautifulSoup(source.content, 'html.parser') >>> h3 = soup.find('h3') >>> p = h3.find_all_next('p')[8] >>> p <p>Croydon Tramlink mast references can be found on the <a href="http://www.croydon-traml... >>> hyper_txt = get_hypertext(hypertext_tag=p, md_style=True) >>> hyper_txt 'Croydon Tramlink mast references can be found on the [Croydon Tramlink Unofficial Site](...