我将购买将运行lineageOS的新智能手机。
由于对智能手机的正确选择始终取决于手机的价格,因此我想生成一个包含lineageOS支持的所有设备的价格表。
[我不知道该怎么做,因为我的主要技能是关于嵌入式编程的,而不是有关Web /解析/ rest-API或Web技术的其他所有内容。
所以这是我到目前为止的计划:
wget
下载devices homepage或lineageOS statistics web serviceawk
和/或grep过滤掉所有设备的首页源代码对每个设备字符串使用bash
for循环调用wget
进入idealo或amazon的restFull-API(这真的是该技术名称正确吗?)。这可能看起来像这样:
for device in $DEVICES; do wget https://www.idealo.de/preisvergleich/MainSearchProductCategory.html?q=$device > $device.html
使用grep
通过过滤第一个搜索项目来查找带有设备价格的行。这可能像这样丑陋:
grep -A999999 pageContent-wrapper device.html | grep -m1 -A2 ">price-prefix" | grep "€"
使用cut
从行中提取价格本身
通过使用类似下面的命令输出格式正确的列表:
echo $device $price
好吧,我认为这应该可行,但是生成列表似乎是一种非常丑陋且性能不佳的方法。
如何轻松列出所有lineageOS ROM的价格?
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/
)
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