|
|
| def return_buisnessinsider_withoutads(URL): |
| import requests |
| from bs4 import BeautifulSoup |
| r= requests.get(URL) |
| html_content = r.content.decode('utf-8') |
|
|
| |
| soup = BeautifulSoup(html_content, 'html.parser') |
|
|
| |
| div_tag = soup.find('div', class_='content-lock-content') |
|
|
| |
| if div_tag: |
| |
| text_content = div_tag.get_text(separator='\n', strip=True) |
|
|
| |
| return f"{text_content}" |
| else: |
| return "Div tag with class 'content-lock-content' not found." |
|
|
|
|
| |
| import panel as pn |
|
|
| URL = "https://www.businessinsider.com/chatgpt-trading-stocks-high-returns-simulated-study-prompt-used-2023-7?r=US&IR=T" |
|
|
| text_input = pn.widgets.TextInput(name='BusinessInsider URL', value=URL , placeholder='Enter Business insdier URL here...') |
|
|
| button = pn.widgets.Button(name='Click me', button_type='primary') |
|
|
| pn.config.sizing_mode = 'stretch_height' |
| |
| |
|
|
| pn.extension('texteditor') |
| pn.config.sizing_mode = 'stretch_width' |
|
|
| def return_editor(textinput): |
| TXT = return_buisnessinsider_withoutads(textinput) |
| return pn.widgets.TextEditor(value = TXT , toolbar=[ |
| ['bold', 'italic', 'underline', 'strike'], |
| ['blockquote', 'code-block'], |
|
|
| [{ 'header': 1 }, { 'header': 2 }], |
| [{ 'list': 'ordered'}, { 'list': 'bullet' }], |
| [{ 'script': 'sub'}, { 'script': 'super' }], |
| [{ 'indent': '-1'}, { 'indent': '+1' }], |
| [{ 'direction': 'rtl' }], |
|
|
| [{ 'size': ['small', False, 'large', 'huge'] }], |
| [{ 'header': [1, 2, 3, 4, 5, 6, False] }], |
|
|
| [{ 'color': [] }, { 'background': [] }], |
| [{ 'font': [] }], |
| [{ 'align': [] }], |
|
|
| ['clean'] |
| ] , sizing_mode='stretch_height') |
|
|
|
|
| pn.Column( |
| text_input,button, |
| pn.bind(return_editor , text_input) |
| ).servable(title="Get BusinessInsider Article") |