Saturday, April 15, 2017

A bit of script for downloading images from a website

So I wanted to download only images from this one website for archival usage. After looking at all ready available page, I couldn't find anything suiting for my purpose. So I decided to throw in a little shell-script.
It went on as follows:
The pages are incremental in index. So I can use a while loop to fetch all pages one by one. Done.
Need to fetch the page. Wget is fine. Done.
Then I need to look for the image URL in retrieved HTML. Hmm. Bit of grep with cut does that. Done.
Next get the actual image. Again prepare the image URL and wget. Done.

Error handling? Gaah. Nothing since this is not that trivial.

After testing for few pages it was golden.

So I put it up with counter loop of hundred images at one time. That's because this script is kind of slow since I don't know nor care to put in multithreading in shellscript. Gaah.
Plus as I later found out having 100's counter is good since wget hung out when the net went down for a moment, and I had to restart the script from that page count.

And somehow https proxy is set on my laptop. Why, god only knows. Below is the script.


export https_proxy=""

while [ $count -gt 10800 ]

echo "Downloading page $count..."

content=$(wget$count -q -O -)
#echo $content
echo "Page downloaded!"

line=$(echo $content | grep -b -o "class=\"main-photo\"")
offset=$(echo $line| cut -d : -f1)
img=""$(echo $content | cut -c$offset-$offset1 | tail -c18)

echo "Getting Image: "$img"..."
wget $img -q
#echo "count: $count"

exit 0

First big problem with our bike Hero Duet

Yesterday we went out for an outing on our bike. It was about 90kms round trip. We left in morning and planned to be back by noon. Going was nice, with normal weather. After reaching the place and sightseeing for about couple of hours we left by 11:30AM.
We could feel the heat. It was not scorching yet, but we felt like we should have left an hour early, since it was easily an hour and half's ride back with all the traffic. So we were only 10kms away when the scooter lost power. We tried electric start first, but it won't start. Then we tried kick start, and still nothing. So we searched the net and found a mechanic and had him sent someone over.
Then after 45 minutes couple of young mechanics reached us. After fiddling with the scooter they managed to kick start it. Initial prognosis was dead air filter. So we rode to their garage, and got it replaced in about half-an-hour. In Hero Duet the filter comes as a block of striped foam. In bikes it's often a round hose-like design. It was pretty gunky from what we saw. The replacement cost us about 250Rs, that plus the mechanic visit of 150Rs, totalled to 400Rs.
At least now the scooter runs better.

Tuesday, April 11, 2017

LG phones bootloop/ restarts/ slowness issues

Been reading about the troubles with LG. To be frank, LG actually has crappy phones. Their mid range is non-existent and their high end is in search of identity. Add in these QA issues. I mean come on.... I have seen phones getting literally cooked at about 45-50 degrees when gaming and they did not fail - e.g. my Nubia Z9 mini and few more older phones. If LG cannot make a phone motherboard, they need to be put out of phone making business.
Latest news is they have a Class Action lawsuit in US. Hmmm let everybody know LG hardware is crap.
For comparisons we have not heard such things from almost all other manufacturers. And please leave aside chinese knock-offs. They can't even align their plastic edges. Haha.