Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用beautifulsoup将VBA转换为Python_Python_Excel_Vba_Beautifulsoup - Fatal编程技术网

使用beautifulsoup将VBA转换为Python

使用beautifulsoup将VBA转换为Python,python,excel,vba,beautifulsoup,Python,Excel,Vba,Beautifulsoup,您是否收到错误消息(回溯)?在问题中显示它(不在评论中)。什么是页面源?可能问题出在源HTML上,而不是BS上。我没有收到任何错误,因为它没有输入我编写的第一个if条件-if child.name==“H4”:标准方法-使用print()查看变量-print(child.name)中的内容。我希望您有h4,而不是h4。您可以检查图像中所附的完整源代码YUP我在之后立即进行了打印-对于child中的child:print(child.text),这是在DIV类中给我完整的文本。是否收到错误消息(回


您是否收到错误消息(回溯)?在问题中显示它(不在评论中)。什么是页面源?可能问题出在源HTML上,而不是BS上。我没有收到任何错误,因为它没有输入我编写的第一个if条件-if child.name==“H4”:标准方法-使用
print()
查看变量-
print(child.name)
中的内容。我希望您有
h4
,而不是
h4
。您可以检查图像中所附的完整源代码YUP我在之后立即进行了打印-对于child中的child:print(child.text),这是在DIV类中给我完整的文本。是否收到错误消息(回溯)?在问题中显示它(不在评论中)。什么是页面源?可能问题出在源HTML上,而不是BS上。我没有收到任何错误,因为它没有输入我编写的第一个if条件-if child.name==“H4”:标准方法-使用
print()
查看变量-
print(child.name)
中的内容。我希望您有
h4
,而不是
h4
。您可以检查图像中附带的完整源代码。我在之后立即进行了打印-对于children中的child:print(child.text),这将为我提供DIV类中的完整文本
For Each hdiv In doc.getElementsByClassName("offset1 transport-plan location-detail well well-white margin20right")
                      For Each child In hdiv.Children
                         If child.tagName = "H4" Then
                            location = child.innerText    
                        ElseIf child.tagName = "TABLE" Then
                          If row.tagName = "TBODY" Then
                            For Each row1 In row.Children
                               do something

                           If row1.tagName = "TR" Then
                                For Each row2 In row1.Children
                                  If row2.innerText <> "" Then
                                    activity = row2.innerText
soup = BeautifulSoup(driver.page_source)

for each_div in soup.findAll("div", { "class" : "offset1 transport-plan location-detail well well-white margin20right" }):
    children = each_div.findChildren()
    for child in children:
        if child.name == "H4":
            print(child.text)

        elif child.name == "TABLE":
            print (child.text)