Weasyprint output not displaying most of the original webpage?

Viewed 190

I have a python webscraper that collects municipal data. The website itself does not have an integrated method of downloading the data, so I have written a script to save and download the html page as a pdf using weasyprint. However, the webpage looks like this in the pdf output:

pdfoutput

This is how the webpage looks in a browser: enter image description here

Any ideas on how to fix the pdf output so that the information in the table under "Permits Issued in the past 30 days" displays correctly?

Script code:

from classes.main import *
import weasyprint
import datetime

#Opening website 
url = "https://www.dnv.org/property-development/look-building-and-trades-permits"

with Display(visible=False, size=(1200,1500)):
  print("display initiated")
  browser.get(url)
  print("browser loaded")

  #Wait for page to load
  wait.until(EC.presence_of_element_located((By.ID, "main-content")))
  print("Page loaded")

  browser.find_element_by_xpath('//*[@id="lastcalendardays"]').click()
  sleep(2)

  current_date_and_time = datetime.datetime.now()
  current_date_and_time_string = str(current_date_and_time)

  pdf = weasyprint.HTML('https://www.dnv.org/property-development/look-building-and-trades-permits').write_pdf()
  open('/bm/data/' + current_date_and_time_string + ' - northvandistrict' + '.pdf', 'wb').write(pdf)

print("end of code")
browser.quit()
0 Answers
Related