我在分割中获取当前页面并通过lxml运行它时遇到了一些麻烦。由于使用splinter登录,我无法直接通过请求。 解决了Pt1
const type = {
link: 'dark-blue'
};
type.text = `${type.link} f2`;
export type;
这导致 AttributeError:' str'对象没有属性'内容' 我感觉很困惑这个。
Pt2解决了,我愚蠢 现在我的第二个xpath生成 [] 而不是像成绩一样的完整数组
browser.visit('www.site.com') #Access
browser.fill('username', 'userName') #Login
browser.fill('password', 'sekretPass') #Login
button = browser.find_by_name('commit') #Login
button.click() #Login
divs = browser.find_by_id("child-89751")
within = divs.first.find_by_name('calculated-grade')
if browser.is_text_present('Current Class Schedule'):
print("Success")
print(within)
page = browser.html
tree = html.fromstring(page.content)
grades = tree.xpath('//span[@class="numeric-grade"]/text()')
print ('Grades: ', grades)