Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Filter output in curl


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Filter output in curl

Hello guys,

I'm writing a little script which sends me sms with my shell script via api of a sms provider.

problem is I can't filter my curl output for this site:

site url:
Code:
http://fahrplan.oebb.at/bin/query.exe/dn?start=1&_charset=UTF-8&REQ0JourneyProduct_list=0:1111111111011000-000000.&SALL=1&ZALL=1&scotty_advancedSearchMode=0&S=mureck&Z=graz%20puntigam&REQ0JourneyDate=21.08.2014&time=04:00&timeSel=depart

this is what i got so far, but I don't know how to filter everything out, I just want the times and also only the "ab time" like
Quote:
05:08 ab
Code:
#!/bin/bash
URL='http://fahrplan.oebb.at/bin/query.exe/dn?start=1&_charset=UTF-8&REQ0JourneyProduct_list=0:1111111111011000-000000.&SALL=1&ZALL=1&scotty_advancedSearchMode=0&S=mureck&Z=graz%20puntigam&REQ0JourneyDate=21.08.2014&time=04:00&timeSel=depart'

echo "Now:" `date +%H:%M:%S`
for URL in $URLS; do
echo "$URL:" | sed 's/.*=.*=/Route /'
curl -s $URL \

done

cheers
# 2  
Once again I haul out my micro xml parser for these questions... It looks like you want the contents of the very first <div class="planed">...</div> block.

Code:
$ cat planed.xml

BEGIN {
        FS=">"
        RS="<"
}

NR==1 { next } # The first "line" is blank when RS=<
/^[!?]/ {       next    }               # Skip XML specification junk
{       gsub(/[\r\n]*$/, " ");  }       # Clean up newlines

# Handle open-tags
match($0, /^[^\/ \r\n\t>]+/) {
        TAG=substr(toupper($1), RSTART, RLENGTH);
        TAGS=TAG "%" TAGS;
}

# Handle close-tags
/^[\/]/ {
        sub(/^\//, "", $1);
        sub("^.*" toupper($1) "%", "", TAGS);
        next;
}

(TAGS ~ /^DIV%/) && ($1 ~ /planed/) {
        gsub(/[\r\n]/, "", $2);
        print $2;
        exit;
}

$ awk -f planed.awk input.html

05:08 ab

$

The code highlighted in red is the statement which extracts the tag you want. The rest is generic XML parsing code.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Filename output in curl
locoroco
How can I get the name of the default output filename from curl using the argument -O? Using -o one can choose a filename. I want to get the name of the original file, but don't understand how to get it. curl -o filename http://www.website.com curl -O http://www.website.com The...... Web Development
3
Web Development
Extracting urls from curl output
jozo95
Hello. I use curl to fetch a website, then, I want to extract the URLs from this curls output. I tried both sed and grep, but couldnt figure it out. Ive tried : sed -n 's/href="\(*\).*/\1/p' results.txt and grep -o grep -o '<a href="http://*.*.*/*">' results.txt. What pattern...... Shell Programming and Scripting
6
Shell Programming and Scripting
Encapsulating output of CURL and/or WGET
SkySmart
i use curl and wget quite often. i set up alarms on their output. for instance, i would run a "wget" on a url and then search for certain strings within the output given by the "wget". the problem is, i cant get the entire output or response of my wget/curl command to show up correctly in...... Shell Programming and Scripting
3
Shell Programming and Scripting
Getting cURL to output verbose to a file
caramandi
This is about to drive me crazy. What I want to do is simple: output ALL the verbose information from curl to a file I have read the manual, tried several options and searched this forum but no salvation... I'm using curl -k -Q "command" --user user:passwd --ftp-pasv --ftp-ssl -v...... Shell Programming and Scripting
1
Shell Programming and Scripting
script to output curl result as html
squidusr
hi, new to scripting and would like to know how can I have a script which will curl a few URLs and have the results such as the URLs being curled, dns lookup time, connection time, total time, etc save in a html format in a form of table with column and rows. thank you.... Shell Programming and Scripting
4
Shell Programming and Scripting

Featured Tech Videos