<jupyter_start><jupyter_text>**url**https://www.piramal.com/news-media/press-release/<jupyter_code>import pandas as pd,requests,bs4,re,time,io,pdftotext
from goose3 import Goose
from datetime import datetime
from bs4 import BeautifulSoup
import warnings
warnings.filterwarnings("ignore")

%autosave 1
SITE_NAME='Piramal'

DOMAIN = "https://www.piramal.com"

SITE_LINK="https://www.piramal.com/news-media/press-release/"
def remove_esc_chars(text):
    return text.replace("\n", " ").replace("\t", " ").replace("\r", " ")
def parse_webpage_bs(search_url):
    
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0"}
    try:
        site_request = requests.get(search_url, headers=headers, timeout=10)
    except requests.exceptions.RequestException as e:
        print(e)
        site_request = None
    if site_request != None and site_request.status_code==200:
        site_soup = bs4.BeautifulSoup(site_request.content, "lxml")
    else:
        site_soup = None
    return site_soup
article_list = []
url = SITE_LINK
soup = parse_webpage_bs(url)
if soup != None:
    elements = soup.findAll('td',{'class' :'nseardis'})
    for element in elements:
        try:
            #title
            title = element.find('p').text.strip()

            #published_date,link
            date = element.find('div')
            published_date = date.text.split(" ")[1].strip()
            link = date.find('a')['href']

            #text
            r = requests.get(link)
            f = io.BytesIO(r.content)
            reader = pdftotext.PDF(f)
            text = ""
            for x in range(0,len(reader)):
                text += remove_esc_chars(reader[x])

            #thumbnail and author
            thumbnail = "https://www.piramal.com/wp-content/uploads/2020/05/logo.svg"
            author = SITE_NAME

            article = (published_date,title,text,link,thumbnail,author)
            article_list.append(article)
            print(published_date,title)
        except:
            pass
        
        print(str(len(elements)- elements.index(element) -1) + " pages remaining..",end="\r")
temp_df = pd.DataFrame(article_list,columns=['date','title','article','url','thumbnail','author'])
temp_df
#to csv
temp_df.to_csv('Piramal news.csv',index = False)

#to json
temp_df.to_json('Piramal news.json')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13970893970893972, 'fraction_numerical': 0.017463617463617465, 'mean_word_length': 2.8312101910828025, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '447609', 'license': 'MIT', 'n_tokens_mistral': 831, 'n_tokens_neox': 792, 'n_words': 140, 'path': 'piramal-text-from-pdf/piramal_bs4.ipynb', 'repo_name': 'heyakshayhere/bs4', 'size': '2405'}