如何轻松列出所有lineageOS ROM的价格?

问题描述 投票:-1回答:1

我将购买将运行lineageOS的新智能手机。

由于对智能手机的正确选择始终取决于手机的价格,因此我想生成一个包含lineageOS支持的所有设备的价格表。

[我不知道该怎么做,因为我的主要技能是关于嵌入式编程的,而不是有关Web /解析/ rest-API或Web技术的其他所有内容。

所以这是我到目前为止的计划:

  1. 使用wget下载devices homepagelineageOS statistics web service
  2. [使用awk和/或grep过滤掉所有设备的首页源代码
  3. 对每个设备字符串使用bash for循环调用wget进入idealoamazon的restFull-API(这真的是该技术名称正确吗?)。这可能看起来像这样:

    for device in $DEVICES; do wget https://www.idealo.de/preisvergleich/MainSearchProductCategory.html?q=$device > $device.html

  4. 使用grep通过过滤第一个搜索项目来查找带有设备价格的行。这可能像这样丑陋:

    grep -A999999 pageContent-wrapper device.html | grep -m1 -A2 ">price-prefix" | grep "€"

  5. 使用cut从行中提取价格本身

  6. 通过使用类似下面的命令输出格式正确的列表:

    echo $device $price

好吧,我认为这应该可行,但是生成列表似乎是一种非常丑陋且性能不佳的方法。

如何轻松列出所有lineageOS ROM的价格?

bash grep restful-url lineageos
1个回答
0
投票

我们使用正确的HTML解析器和

while read device; do
  printf '%s %s\n' "$device" $(
  saxon-lint --html --xpath '(//div[@class="offerList-item-priceMin"])[1]/text()' \
  "https://www.idealo.de/preisvergleich/MainSearchProductCategory.html?q=$device"
)
done < <(
  saxon-lint --html --xpath '//a[starts-with(@href, "/model")]/text()' \
  https://stats.lineageos.org/
)

检查saxon-lint

输出

m8 128,22 €
bacon 1,89 €
riva 224,99 €
cancro 8,35 €
klte 
j7eltexx 
t0lte 
wt88047 
i9300 35,58 €
mido 558,00 €
...

注意

通过a5y17lte测试https://www.idealo.de/preisvergleich/MainSearchProductCategory.html?q=a5y17lte(例如),没有结果。

该站点不可靠,另一个示例:bacon 1,89 €不是电话:D

© www.soinside.com 2019 - 2024. All rights reserved.