Xander
Xander

Reputation: 69

Sed extract link from html page

I'm trying to write a module for uploading with plowshare but I have problem with parsing from upload page.

I need to extract upload_url

<script type="text/javascript">

  upload_url: "http://s73.domain.com/?action=uploadfiles&user_id=TVRnN21ESX2c&secret_code=f4r6w35q639ih7oi62u674ae91453697", // Relative to the SWF file (or you can use absolute paths)

After I login, I load page for upload and then I need to extract upload_url

I try with:

'upload_url:' '"\([[:digit:]]|http[:]//[^ ])*'

but I get this error

sed: -e expression #1, char 60: Unmatched ( or \(

Upvotes: 0

Views: 74

Answers (1)

Cyrus
Cyrus

Reputation: 88563

sed:

sed -nE 's/.*upload_url: "([^"]+).*/\1/p' filename

Output:

http://s73.domain.com/?action=uploadfiles&user_id=TVRnN21ESX2c&secret_code=f4r6w35q639ih7oi62u674ae91453697

grep:

grep -oP 'upload_url: "\K[^"]+' filename

awk:

awk -F "\"" '/upload_url/ {print $2}' filename

Upvotes: 1

Related Questions