- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 https://us.letgo.com/en 中收集我所在地区的二手元素对于个人项目。我发现此视频很有帮助 https://youtu.be/EelmnSzykyI .但是,视频无法解决一些细微差别。
我需要的信息是通过 json 异步加载的。该网站每次滚动加载 15 个项目(初始加载除外,其中包含 30 个项目)。 json 对象如下所示:https://search-products-pwa.letgo.com/api/products?country_code=US&offset=0&quadkey=0320030123201&num_results=30&distance_type=mi接下来要加载的 15 个项目如下所示:https://search-products-pwa.letgo.com/api/products?country_code=US&offset=30&quadkey=0320030123201&num_results=15&distance_type=mi
当我加载第一个响应 data = json.loads(response.text)
时,它会返回包含 30 个项目的列表。第一项如下所示:
{'attributes': None,
'category_id': 5,
'created_at': '2018-02-12T15:40:56+00:00',
'currency': 'USD',
'description': None,
'featured': False,
'geo': {'city': 'Asheville',
'country_code': 'US',
'distance': 1.1703344331099,
'lat': 35.5889898,
'lng': -82.5308015,
'zip_code': '28805'},
'id': '6080a1db-b2af-44c2-bfd8-4cc7f1ded17f',
'image_information': 'brown ukulele',
'images': [{'id': 'b8e78e2e-65c4-4062-b89e-c775ef9f6bc9',
'url': 'https://img.letgo.com/images/ab/da/e2/f6/abdae2f68e34170d8f1f22d2473d1153.jpeg'}],
'language_code': 'US',
'name': None,
'owner': {'avatar_url': '',
'banned': False,
'city': 'Asheville',
'country_code': 'US',
'id': 'fb0f8657-0273-4fac-ba77-9965a1dc8794',
'is_richy': False,
'name': 'Brock G',
'status': 'active',
'zip_code': '28805'},
'price': 100,
'price_flag': 2,
'rejected': False,
'status': 1,
'thumb': {'height': 1280,
'url': 'https://img.letgo.com/images/ab/da/e2/f6/abdae2f68e34170d8f1f22d2473d1153.jpeg?impolicy=img_200',
'width': 960},
'updated_at': '2018-02-12T15:41:34+00:00'}
我的目标是创建一个 for 循环并提取每个项目,然后继续执行下一个加载另外 15 个项目的请求,但我不确定如何执行此操作。请注意,额外的请求参数如下:
更新
我快接近了,但似乎无法弄清楚如何简单地更新本质上递归调用自身的函数中的偏移参数:
class LetgoSpider(scrapy.Spider):
name = 'letgo'
allowed_domains = ['letgo.com/en']
start_urls = ['https://search-products-pwa.letgo.com/api/products?country_code=US&offset=0&quadkey=0320030123201&num_results=50&distance_type=mi']
def parse(self, response):
data = json.loads(response.text)
for used_item in data:
if len(data) == 0:
break
try:
title = used_item['name']
price = used_item['price']
description = used_item['description']
date = used_item['updated_at']
images = [img['url'] for img in used_item['images']]
latitude = used_item['geo']['lat']
longitude = used_item['geo']['lng']
except Exception:
pass
yield {'Title': title,
'Price': price,
'Description': description,
'Date': date,
'Images': images,
'Latitude': latitude,
'Longitude': longitude
}
i = 0
for new_items_load in response:
i += 50
offset = i
new_request = 'https://search-products-pwa.letgo.com/api/products?country_code=US&offset=' + str(i) + \
'&quadkey=0320030123201&num_results=50&distance_type=mi'
yield scrapy.Request(new_request, callback=self.parse)
最佳答案
不确定我是否理解你的问题。
如果你只需要知道如何定义参数,这可能是一种方式:
let offset, num_results;
for(let i = 0; i < max; i += 15) {
offset = i;
num_results = i + 15;
[do the request with the parameters values]
}
关于javascript - 使用 Scrapy 抓取无限滚动的网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48751029/
我有这个网站,这个特定页面是安全的,但是当它回发时,它回发到一个不安全的页面。如何解决? 我正在使用 ASP.NET 向导。我有这个页面 - checkout.aspx,页面包含这个控件 checko
我有 2 个 azure 网站 - 两个独立的项目 我现在有 2 个网址: myazurewebsite.azurewebsites.net myazureblog.azurewebsites.net
我有 2 个 azure 网站 - 两个独立的项目 我现在有 2 个网址: myazurewebsite.azurewebsites.net myazureblog.azurewebsites.net
环境: 旧网站: React 托管在 Heroku URL( http://sameurl.com ) 新网站: Java 托管在 Heroku URL ( http://sameurl.com )
我已在 Windows Azure 上注册了一个测试帐户来对其进行测试。我构建了一个 Hello world ASP.NET Web 应用程序 + 数据库只是为了测试。 我安装了 Visual Stu
我有一个可以收集和显示各种测量值的产品(不会详细介绍)。正如人们所期望的那样,显示部分是一个数据库+建立在其之上的网站(使用 Symfony)。 但是,我们可能还会创建一个 API 来向第三方公开数据
这个问题在这里已经有了答案: Software keyboard resizes background image on Android (16 个答案) 关闭 8 年前。 我有一个类似的问题:So
这个问题似乎很常见,但我真的无法根据现有答案解决问题。 我有一个简单的 maven 项目,没有任何复杂的部署配置等,并且想在点击“mvn site”时生成一个 Maven CheckStyle 报告。
有没有人看过有关何时进行横向扩展与纵向扩展的最佳选择的任何分析或信息。什么时候一个比另一个更有意义。 目前,在标准模式和基本模式下,2 个小型实例的费用与 1 个中型实例的费用相同。 拥有 2 个小型
有没有办法找到 azure 网站何时停止? (我通过门户网站停止了网站,但我不记得是什么时候......) 我正在寻找一些日志,但没有找到任何有用的内容。 谢谢。 最佳答案 您拥有的最接近的是 azu
我目前在 Azure VM 的 IIS 中拥有一个网站。我已将该站点复制到 2 个可用区域中的 2 个虚拟机上。 这可以保护网站免遭停机。 我需要为高负载时刻实现一些可扩展性。这似乎就是创建音阶集的目
我有一个托管在 Azure 上的网站 ( http://mike-ward.azurewebsites.net/ )。我从 Azure 门户设置了一个指向(引用?)我的网站的 Azure CDN。根据
我有一个 Azure 网站(不是 Web 角色),有 2 个槽:生产和暂存。 我只想为生产插槽启用 CDN,而不是为登台启用,问题是我找不到识别主机插槽的方法。 RoleEnvironment 不可用
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等建议的问题。您可以编辑问题,以便可以用事实和引用来回答它。 4年前关
我们正在考虑将一些网站从 Azure 云服务迁移到 Azure 网站(事情似乎就是这样进行的)。显然,我们被明确告知云服务不会保留文件系统状态,因为它们会在机器故障时重新部署。 我假设网站是基于 Bl
我有一个 Azure 网站,需要使用在 VM 上运行的 Elasticsearch 服务。 虽然我需要能够锁定对 Elasticsearch 的访问,以便只有 Azure 网站可以访问它,但我似乎无法
我有一个 azure 网站,位于 yis3.azurewebsites.net - 我已将其提升为“共享”网站,以便我可以使用自定义域。我拥有从 123-reg.co.uk 购买的域名 yorkshi
我正在使用 abcPDF 动态创建 PDF。 我想保存这些 PDF,以便客户随时检索。最简单的方法(也是我现在在当前服务器上所做的方法)是将完成的 PDF 保存到文件系统。 看来我一直坚持使用 blo
我们正在尝试了解 Windows Azure 管理 API 为 Azure 网站(而非 Webroles)返回的监控数据的复杂性 例如,下图描述了为 CPUTime 检索的数据点。它似乎表明,在晚上
看起来真的很愚蠢,因为我找不到它: 门户网站似乎不太直观,我如何为一个“网站”付费并在其中运行最多 500 个网站?我想当我通过单击左下角的加号添加“网站”时,我添加了整个虚拟机而不是子站点。如何仅添
我是一名优秀的程序员,十分优秀!