Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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
Python HTML隐藏元素_Python_Html - Fatal编程技术网

Python HTML隐藏元素

Python HTML隐藏元素,python,html,Python,Html,事实上,我正试图编写一个小“GPS”,但由于日常限制,我无法使用GoogleAPI 我决定使用一个网站“米其林”,它为我提供了两个地址之间的距离。我创建了一个小代码来获取我需要的所有URL地址,如下所示: import pandas import numpy as np df = pandas.read_excel('C:\Users\Bibi\Downloads\memoire\memoire.xlsx', sheet_name='Clients') df2= pandas.read_e

事实上,我正试图编写一个小“GPS”,但由于日常限制,我无法使用GoogleAPI

我决定使用一个网站“米其林”,它为我提供了两个地址之间的距离。我创建了一个小代码来获取我需要的所有URL地址,如下所示:

import pandas

import numpy as np

df = pandas.read_excel('C:\Users\Bibi\Downloads\memoire\memoire.xlsx', sheet_name='Clients')

df2= pandas.read_excel('C:\Users\Bibi\Downloads\memoire\memoire.xlsx', sheet_name='Agences')

matrix=df.as_matrix(columns=None)

clients = np.squeeze(np.asarray(matrix))

matrix2=df2.as_matrix(columns=None)

agences = np.squeeze(np.asarray(matrix2))

compteagences=0

comptetotal=0

for j in agences:

    compteclients=0

    for i in clients:

        print agences[compteagences]

        print clients[compteclients]

        url ='https://fr.viamichelin.be/web/Itineraires?departure='+agences[compteagences]+'&arrival='+clients[compteclients]+'&arrivalId=34MTE1MnJ5ZmQwMDMzb3YxMDU1ZDFvbGNOVEF1TlRVNU5UUT1jTlM0M01qa3lOZz09Y05UQXVOVFl4TlE9PWNOUzQzTXpFNU5nPT1jTlRBdU5UVTVOVFE9Y05TNDNNamt5Tmc9PTBqUnVlIEZvbmQgZGVzIEhhbGxlcw==&index=0&vehicle=0&type=0&distance=km&currency=EUR&highway=false&toll=false&vignette=false&orc=false&crossing=true&caravan=false&shouldUseTraffic=false&withBreaks=false&break_frequency=7200&coffee_duration=1200&lunch_duration=3600&diner_duration=3600&night_duration=32400&car=hatchback&fuel=petrol&fuelCost=1.393&allowance=0&corridor=&departureDate=&arrivalDate=&fuelConsumption='

        print url

        compteclients+=1

        comptetotal+=1

    compteagences+=1
我所有的数据都在Excel上,这就是我使用pandas库的原因。我有我的项目所需的所有URL

虽然,我想提取所需的公里数,但有一个小问题。在源代码中,我没有我需要的信息,所以我不能用Python提取它。。。网站的呈现方式如下:

当我点击“检查”时,我可以找到所需的信息(在左边),但在源代码上找不到(在右边)。。。有人能帮我吗?

我已经试过了,但没有成功:

import os

import csv

import requests

from bs4 import BeautifulSoup

requete = requests.get("https://fr.viamichelin.be/web/Itineraires?departure=Rue%20Lebeau%2C%20Liege%2C%20Belgique&departureId=34MTE1Mmc2NzQwMDM0NHoxMDU1ZW44d2NOVEF1TmpNek5ERT1jTlM0MU5qazJPQT09Y05UQXVOak16TkRFPWNOUzQxTnpBM01nPT1jTlRBdU5qTXpOREU9Y05TNDFOekEzTWc9PTBhUnVlIExlYmVhdQ==&arrival=Rue%20Rys%20De%20Mosbeux%2C%20Trooz%2C%20Belgique&arrivalId=34MTE1MnJ5ZmQwMDMzb3YxMDU1ZDFvbGNOVEF1TlRVNU5UUT1jTlM0M01qa3lOZz09Y05UQXVOVFl4TlE9PWNOUzQzTXpFNU5nPT1jTlRBdU5UVTVOVFE9Y05TNDNNamt5Tmc9PTBqUnVlIEZvbmQgZGVzIEhhbGxlcw==&index=0&vehicle=0&type=0&distance=km&currency=EUR&highway=false&toll=false&vignette=false&orc=false&crossing=true&caravan=false&shouldUseTraffic=false&withBreaks=false&break_frequency=7200&coffee_duration=1200&lunch_duration=3600&diner_duration=3600&night_duration=32400&car=hatchback&fuel=petrol&fuelCost=1.393&allowance=0&corridor=&departureDate=&arrivalDate=&fuelConsumption=")

page = requete.content

soup = BeautifulSoup(page, "html.parser")

print soup

查看页面的检查器,实际的路由是通过对的JavaScript调用完成的


您需要的数据似乎在该响应中,从
\u scriptLoaded(
)开始(因为它是一个JavaScript对象文本,您可以使用Python内置的JSON库将数据加载到
dict
)中)

谢谢您的回答,我会尝试这样做!