I want to scrape the date from a webpage, and the text of the date (after script tag) is injected by JavaScript: I want to scrape it using Beautifulsoup only, not selenium
<div class="row">
<span class="LName"><a target="_blank" href="http://google.com">[me too]</a></span>
<script language="Javascript" type="text/javascript">formatDate('2020,5,23,09,00,00',1)</script>6/23/2020 10:00 Tuesday
</div>
this is the code used to try scraping the date text:
headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0'}
r = requests.get(u, headers=headers)
soup = BeautifulSoup(r.content, 'html.parser')
I try :
soup.select('div.row > script')[0].get_text()
returns:
"formatDate('2020,5,23,09,00,00',1)"
and :
soup.select('div.row')[0].get_text()
returns:
"\n[me too] formatDate('2020,5,23,09,00,00',1)\n"
when I use Chrome to inspect the tag, I can see the date text after the script tag
when I execute:
soup.select('div.row')
it returns the tag without the date text
I want to scrape only with Beautifulsoup, not selenium