Поиск по блогу

четверг, 3 июля 2014 г.

Смотрю видеоподборку от theurbanpenguin о том, как с Curl постить в Twitter полуавтоматом...

В видео "BASH Lesson tutorial - Use cURL to post to Twitter " учат, как щебетать ... с помощью fortune. В "LINUX: HTTP-Scripting-With-curl ". После более детельного знакомства (посмотрел, как форируется строка команды curl ...)с другими видео (здесь штуки 4) понял, что надо переходить к чтению статей по конкретным опциям...

Команды из видеоролика

In []:
su 
apt-get install fortune
In [2]:
!fortune
Green light in A.M. for new projects.  Red light in P.M. for traffic tickets.


In []:
curl -u "username":"password" -d status="Helo Word" http://twitter.com/statuses/update.xml
curl -u "username":"password" -d status="fortune" http://twitter.com/statuses/update.xml
В первом случае появится новый твит со строкой "Helo Word", а во втором будет опубликовано выражение после выполнения команды fortune
In [1]:
!fortune
Someone whom you reject today, will reject you tomorrow.


In []:
-d, --data <data>

(HTTP) Sends the specified data in a POST request to the HTTP server, in a way that can emulate as if a user has filled in an HTML
form and pressed the submit button. 

Note that the data is sent exactly as specified with no extra processing (with all newlines cut off). 
The data is expected to be "url-encoded". 
This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. 

Compare to -F/--form. If this option is used more than once on the same command line, 
the data pieces specified will be merged together with a separating "&" character. 
Thus, using '-d name=daniel -d skill=lousy' would generate a POST chunk that looks like 'name=daniel&skill=lousy'. 

LINUX: HTTP-Scripting-With-curl

In []:
wget www.qa.com
w3m www.qa.com
Эти две команды загружают страницу сайта сначала в папку, потом в консоль
In []:
kiss@kali:~/Desktop/curl_wget$ wget www.qa.com
--2014-06-30 21:19:49--  http://www.qa.com/
Resolving www.qa.com (www.qa.com)... 193.108.37.110
Connecting to www.qa.com (www.qa.com)|193.108.37.110|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 43248 (42K) [text/html]
Saving to: `index.html.1'

100%[======================================>] 43,248       116K/s   in 0.4s    

2014-06-30 21:19:51 (116 KB/s) - `index.html.1' saved [43248/43248]

kiss@kali:~/Desktop/curl_wget$ w3m www.qa.com
In [3]:
!w3m -h
w3m version w3m/0.5.3+cvs-1.1055, options lang=en,m17n,image,color,ansi-color,mouse,gpm,menu,cookie,ssl,ssl-verify,external-uri-loader,w3mmailer,nntp,gopher,ipv6,alarm,mark,migemo

usage: w3m [options] [URL or filename]

options:

    -t tab           set tab width

    -r               ignore backspace effect

    -l line          # of preserved line (default 10000)

    -I charset       document charset

    -O charset       display/output charset

    -B               load bookmark

    -bookmark file   specify bookmark file

    -T type          specify content-type

    -m               internet message mode

    -v               visual startup mode

    -M               monochrome display

    -N               open URL of command line on each new tab

    -F               automatically render frame

    -cols width      specify column width (used with -dump)

    -ppc count       specify the number of pixels per character (4.0...32.0)

    -ppl count       specify the number of pixels per line (4.0...64.0)

    -dump            dump formatted page into stdout

    -dump_head       dump response of HEAD request into stdout

    -dump_source     dump page source into stdout

    -dump_both       dump HEAD and source into stdout

    -dump_extra      dump HEAD, source, and extra information into stdout

    -post file       use POST method with file content

    -header string   insert string as a header

    +<num>           goto <num> line

    -num             show line number

    -no-proxy        don't use proxy

    -4               IPv4 only (-o dns_order=4)

    -6               IPv6 only (-o dns_order=6)

    -no-mouse        don't use mouse

    -cookie          use cookie (-no-cookie: don't use cookie)

    -graph           use DEC special graphics for border of table and menu

    -no-graph        use ACII character for border of table and menu

    -s               squeeze multiple blank lines

    -W               toggle wrap search mode

    -X               don't use termcap init/deinit

    -title[=TERM]    set buffer name to terminal title string

    -o opt=value     assign value to config option

    -show-option     print all config options

    -config file     specify config file

    -help            print this usage message

    -version         print w3m version

    -reqlog          write request logfile

    -debug           DO NOT USE


In []:
W3M(1)                                                                             W3M(1)

NAME
       w3m - a text based Web browser and pager

SYNOPSIS
       w3m [options] [URL or filename]

DESCRIPTION
       w3m  is a World Wide Web (WWW) text based client. It has English and Japanese help
       files and an option menu and can be configured to use  either  language.  It  will
       display  hypertext  markup  language  (HTML)  documents  containing links to files
       residing on the local system, as well as files residing on remote systems. It  can
       display  HTML tables and frames.  In addition, it can be used as a "pager" in much
       the same manner as "more"  or  "less".   Current  versions  of  w3m  run  on  Unix
       (Solaris,  SunOS,  HP-UX,  Linux,  FreeBSD,  and EWS4800) and on Microsoft Windows
       9x/NT.

OPTIONS
       At start up, w3m will load any local file or remote URL specified at  the  command
       line.   For  help with runtime options, press "H" while running w3m.  Command line
       options are:

 Manual page w3m(1) line 1 (press h for help or q to quit)
            .....
...

Этот сайт загрузился мгновенно (не Яху...? или просто строку URI нормальную задал..?)

In []:
kiss@kali:~/Desktop/curl_wget$ curl "http://www.qa.com"
Не смог удержаться, и попробовал загрузить файл, сохраненный на винчестер, команда внизу работает! Но только, если указать URI (а не путь...)
In []:
 kiss@kali:~/Desktop/curl_wget$ curl "file:///home/kiss/Desktop/curl_wget/indextml.1"

Есть специальная (особая) команда для загрузки справочника

In []:
curl -M | less # -M, --manual     Manual. Display the huge help text.
In [5]:
curl -n -d status="Curl video will come soon followed by imap/pop3 server" http://twitter.com/statuses/update.xml
  File "<ipython-input-5-9992511a0888>", line 1
    curl -n -d status="Curl video will come soon followed by imap/pop3 server" http://twitter.com/statuses/update.xml
                    ^
SyntaxError: invalid syntax
netrc-File The .netrc file contains login and initialization information used by the auto-login process. It resides in the user's home directory. The following tokens are recognized; they may be separated by spaces, tabs, or new-lines...

Curl Login Tutorial


A tutorial showing you how to use curl to login to different sites and grab their content.
livehttpheaders

В старинном ролике 2007 года рассмтривается скрипт PHP... Но ссылка на livehttpheaders по прежнему жива. Если учесть, что я про него уже где-то читал.... Ставлю в Мозиллу Kali!

Using curl command line tool to send SMS, Twitter, IM, Email, or P



this screencast we're going to talk about using message comes curl 0:04 curls a command-line tool for transferring files with your all syntax 0:09 is a good tool for simulating his actions ira glasser 0:12 our documentation title message p.m. click on picture I reference 0:17 see the four basic net is the message 0:20 a recipe I sending unification getting information 0:24 on one or many occasions and better class 0:28 on this page you can also see them yet many cruel examples 0:32 to run through these examples term Linda 0:35 first let's send notification 0:38 I hosting SNL to notifications Jackson on a message for 0:42 and return RC the same Hasselback but 0:46 with a ninety and the schedule for setting the notifications 0:49 in the second half row for electricity you can also see rover status for each 0:54 recipient this is the current status here 0:57 education said scheduled or otherwise now 1:01 getting information the last 50 notifications and send 1:05 with want a request notifications you can see that the notification just said 1:11 comes last as a scroll up and down any notifications 1:15 hazardous latex ness 1:18 we'll get information back on one particular notification 1:22 by making it get requests to notifications 1:26 ID except now replace at with ID number and the notification area looking for 1:31 in this case and getting information notification 1:34 the Canadian and he said that I sent previously 1:46 finally 1:48 you can fetch all your replies initiated requester 1:51 isaacson in return to receive a rare for class 1:55 with it reply you have the notification and he 1:58 its associated with it dasher reply and how lengthy reply was received 2:02 and listen to miss YouTube views current certification stern message for 2:08 reset their circle and really is that simple
In []:
curl -H "Content-Type: text/html" X GET http://... ... .xml -l


Посты чуть ниже также могут вас заинтересовать

Комментариев нет:

Отправить комментарий