问题描述
所以我有一个 Selenium Scraping 机器人,我正在尝试将这些值共享到 ReportLab Lib 中,以便我可以将信息导出为一个漂亮的 PDF 文件。但是,每当我将它作为函数添加到我的代码中时,我都会收到“TypeError: 'module' object is not callable”。我无法弄清楚,我从错误中猜测我正在导入或将其错误添加到我的代码中。但老实说我不知道如何解决它,谢谢。
from reportlab.lib.enums import TA_JUSTIFY,TA_CENTER
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate,Paragraph,Spacer,Image
from reportlab.lib.styles import getSampleStyleSheet,ParagraphStyle
from reportlab.lib.units import inch
def insight_analytics_page(self):
self.name = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[1]/div/div[2]/button/span[1]/span').text
self.current_followup = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[1]/button/div/div/div[2]/div/div/div[2]/h4[1]').text
self.percentage_change_followup = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[1]/button/div/div/div[2]/div/div/div[2]/h6').text
self.current_visits_to_leases = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[6]/button/div/div/div[2]/div/div/div[1]/h4[1]').text
self.prevIoUs_visit_to_leases = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[6]/button/div/div/div[2]/div/div/div[1]/h4[1]').text
self.prospects_to_visits = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[8]/button/div/div/div[2]/div/div/div[1]/h4[1]').text
self.prospects_to_visits_percentage = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[8]/button/div/div/div[2]/div/div/div[1]/h6').text
self.visits_to_leases_percentage = self.driver.find_element_by_xpath('/html/body/div[1]/div/main/div[2]/div/div[2]/div[6]/button/div/div/div[2]/div/div/div[1]/h6').text
print(self.name)
print('Current Follow-ups ' + self.current_followup)
print('% Change of the Follow-up ' + self.percentage_change_followup)
print('Current visits to leases ' + self.current_visits_to_leases)
print('PrevIoUs visits to leases ' + self.prevIoUs_visit_to_leases)
def pdfReport(self):
document = []
document.append(Spacer(1,20))
document.append(Image(self.name,5*inch,2*inch))
document.append(Paragraph('Report',ParagraphStyle(name='Name',fontFamily='Helvetica',fontSize=36,alignment=TA_CENTER)))
document.append(Spacer(1,50))
return document
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)