Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.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 通过发送http Get请求从JSON响应获取详细信息_Python_Json_Selenium_Web Scraping_Beautifulsoup - Fatal编程技术网

Python 通过发送http Get请求从JSON响应获取详细信息

Python 通过发送http Get请求从JSON响应获取详细信息,python,json,selenium,web-scraping,beautifulsoup,Python,Json,Selenium,Web Scraping,Beautifulsoup,我正在浏览以下产品详细信息: 我想通过使用HTTPGET请求获取注释部分,然后从json响应中获取数据。我请求删除注释,但无法解析数据,例如不知道如何从json响应中获取所需的详细信息。我想搜集每个进行评论的用户的以下信息: 导入请求 从日期时间导入日期时间 导入csv r=requests.get( "https://display.powerreviews.com/m/6406/l/en_US/product/pimprod2014440/reviews?apikey=daa0f241-c

我正在浏览以下产品详细信息:

我想通过使用HTTPGET请求获取注释部分,然后从json响应中获取数据。我请求删除注释,但无法解析数据,例如不知道如何从json响应中获取所需的详细信息。我想搜集每个进行评论的用户的以下信息:

导入请求
从日期时间导入日期时间
导入csv
r=requests.get(
"https://display.powerreviews.com/m/6406/l/en_US/product/pimprod2014440/reviews?apikey=daa0f241-c242-4483-afb7-4449942d1a2b”).json()
以open(“data.csv”,“w”,newline=“”)作为f:
writer=csv.writer(f)
writer.writerow([“昵称”、“位置”、“评论”、“日期”])
对于r[“结果”][0][“评审”]中的项目:
writer.writerow([item[“details”][“昵称”],item[“details”]
[“位置”]、项目[“详细信息”][“注释”]、datetime.fromtimestamp(
整数(项目[“详细信息”][“创建日期”]/1000)))
输出:


请澄清问题的具体内容。看见
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from time import sleep
from bs4 import BeautifulSoup
from os import popen
import requests
import json


Opening Chrome In Debugging Mode
popen('"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --remote-debugging-port=9014')

# declaring chrome optoins 
chrome_options = Options()

# Debug Address of Google Chrome (To Control Actuall Chrome Rather then BOT)
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9014")
# Defining Driver
chrome = webdriver.Chrome(options=chrome_options)

url1 = "https://www.ulta.com/invisible-physical-defense-sunscreen-spf-30?productId=pimprod2014440"

#chrome.maximize_window()
chrome.get(url1)

productPageUrl = chrome.current_url
productPageTitle = chrome.title
soup = BeautifulSoup(chrome.page_source, "lxml")

# productPrice = soup.find("div", class_="ProductPricingPanel").text.strip("Price")
productDetails = soup.find("div", class_="ProductDetail__productContent").text.strip()

http_get_request = 'https://display.powerreviews.com/m/6406/l/en_US/product/' + url1.split('=')[1] + '/reviews?apikey=daa0f241-c242-4483-afb7-4449942d1a2b'
json_data = requests.get(http_get_request)

parse_json = json_data.json()
print(parse_json)