<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Novices Design Courses &#187; Perl</title>
	<atom:link href="http://novices-design-courses.info/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://novices-design-courses.info</link>
	<description>Design Blog</description>
	<lastBuildDate>Thu, 15 Oct 2009 05:09:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Program extract of the bill in system WebMoney</title>
		<link>http://novices-design-courses.info/program-extract-of-the-bill-in-system-webmoney/</link>
		<comments>http://novices-design-courses.info/program-extract-of-the-bill-in-system-webmoney/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 07:04:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[webmoney]]></category>

		<guid isPermaLink="false">http://novices-design-courses.info/?p=65</guid>
		<description><![CDATA[So now the number of Internet &#8211; shops actively grows, and many of them sell the electronic goods (programs, patterns of sites) or render electronic services (conducting statistics of a site, a bulletin board, paid catalogues), and to get{start} to itself own Internet &#8211; shop it is possible. So now the number of Internet &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>So now the number of Internet &#8211; shops actively grows, and many of them sell the electronic goods (programs, patterns of sites) or render electronic services (conducting statistics of a site, a bulletin board, paid catalogues), and to get{start} to itself own Internet &#8211; shop it is possible. <span id="more-65"></span>So now the number of Internet &#8211; shops actively grows, and many of them sell the electronic goods (programs, patterns of sites) or render electronic services (conducting statistics of a site, a bulletin board, paid catalogues), and to get{start} to itself own Internet &#8211; shop it is possible.</p>
<p>Also there is to that a weight of examples &#8211; there are many the fine sites, selling can be only one program or the electronic book. The site began with this http://www.zahodi-ka.ru, originally created by me for sale for the symbolical sum of a self-made toy. Sale has been organized as at all similar projects &#8211; on a page complex{difficult} process of payment which result should become a license key from a toy undersigned. Under indications of the counter of uploadings it was possible to understand, that a toy actively swing, however for half-year to me there has come only one letter with the similar maintenance{contents}: &#8221; Give, please, a key from a toy. From you strongly will not decrease, if not you will receive superfluous 10 roubles &#8220;. (literally the text of the letter I shall not recollect, but there was something similar). I have certainly given a key, if ask, but the conclusion for itself has made, that nobody has bought just because to pay it was simple laziness.</p>
<p>So after that you, I hope, have understood all importance of creation of the convenient user interface. We now also shall engage in it, namely a spelling of the program, avtomatizirujuhhej process of payment of the goods and delivery to his{its} user. First it is necessary to present, as there will be a process and what the program for it is required to write.</p>
<p>Process:</p>
<p>* The user comes on page, enters the WMID (the identifier received at registration in system WebMoney), presses the button &#8220;to pay&#8221; and to him there comes the bill for payment.</p>
<p>* The user pays under the bill and passes under the link specified in parameters of the bill and receives the goods.</p>
<p>Hence it will need 2 programs:</p>
<p>* The program of data processing of the form and an extract of the bill on WMID the user.</p>
<p>* The program of check of payment of the bill and delivery of the goods.</p>
<p>For an extract of the bill on WMID the user it is necessary to execute following https search: https: // w3s.webmoney.ru/asp/Invoice.asp? SL=LoginOfStores and SP=PurseOfStores and CL=LoginOfCust and IN=OrderID and D=Desc and AD=InvAddress and A=Amount and E=Experation and P=Period and RN=RequestN and SS=SignStr (this inofrmacija is resulted on a site of system WebMoney, however if the problem{task} was solved so simply, I would not write this clause{article}). Now about each parameter is more detailed:</p>
<p>SL=LoginOfStores &#8211; the WM-identifier of a web-resource (simply register the new user in system WebMoney for reception of payments from a site and specify it{him} WMID);</p>
<p>SP=PurseOfStores &#8211; a purse of a Web-resource (number{room} of a purse on which payments &#8211; a purse of the user with WMID from the first item{point} will be made);</p>
<p>CL=LoginOfCust &#8211; the WM-identifier of the buyer (this parameter the user specifies, the program obtains the data from the form);</p>
<p>IN=OrderID &#8211; number{room} of the bill (number{room} of the order) on a Web-resource (in shop). Number{room} is generated by the program (1) independently and stored{kept} in base of a Web-resource (shop, service) &#8211; under this number{room} further will be will be defined{determined} a status of the bill (it is paid whether or not). (number{room} should be an integer);</p>
<p>D=Desc &#8211; the description of the goods for which the bill leaves. The parameter should be line from 0 up to 255 symbols;</p>
<p>AD=InvAddress &#8211; the address of delivery of the goods. The parameter should be line from 0 up to 255 symbols (we shall write here the link on which the user can receive the goods. It will be the link to the program (2) to which parameter IN=OrderID will be passed);</p>
<p>A=Amount &#8211; the sum of the bill. The given parameter is formed by the program (1). The parameter should be number with a floating point (a separator &#8211; a point);</p>
<p>E=Experation &#8211; validity of the bill in days (an integer from 0 up to 255);</p>
<p>P=Period &#8211; validity of the patronage of the transaction. The parameter is formed by the program (1.) (the maximal term of the patronage of the transaction at payment of the bill if to specify here 0 the bill will not have term of the patronage);</p>
<p>RN=RequestN &#8211; this parameter is unique growing number. The parameter is formed by the program (1) and should be always more than the same parameter specified in the previous search. It is the best way to form this parameter of the current year, month, day, hour, minute, second and the 100-th seconds. (should be integer 16-ti digit value);</p>
<p>SS=SignStr &#8211; digital the signature of search. He guarantees what your Web-resource has billed.</p>
<p>By preparation https search the Basic problem is formation SS=SignStr. Line PlanStr as the sum of parameters OrderID, LoginOfCust, PurseOfStores, Amount, Desc, InvAddress, Period, Experation, RequestN, described above and precisely in the same order first should be generated. After that it is necessary to make a line of digital signature SignStr of a line of signature PlanStr, for this purpose special module WMSigner to which on an input{entrance} line PlanStr moves is used, and he returns SignStr.</p>
<p>Initial codes of the module can be downloaded, perejdja under the link: http://download.webmoney.ru/WMSigner.zip, then the module should be compiled under that operational system on which your site works. It is possible to send this archive of administration of your hosting and to ask to compile, and it is possible to try success itself, for this purpose we shall create a file poehali.pl with the following code:</p>
<p>*!/usr/bin/perl</p>
<p>system (&#8216; g ++ cmdbase.cpp crypto.cpp md4.cpp rsalib1.cpp signer.cpp wmsigner.cpp &#8216;);</p>
<p>print &#8220;Content-type:text/html\n\n&#8221;;</p>
<p>print &#8221; And nevertheless she spins! &#8220;;</p>
<p>Now we shall create a folder (well, for example wm) in the root of a site and we shall copy there our script and contents of archive WMSigner. Access rights to our script are necessary for putting 711. Now from a line of a browser it is necessary to start a script poehali.pl (to write down a line, for example http://www.zahodi-ka.ru/wm/poehali.pl) and to wait the answer of a script. If on the server there is compiler G ++ and necessary the module in a folder wm after start there is a file a.out which needs to be renamed in wmsigner (small letters).</p>
<p>When the module is available, it is possible to start a spelling of the program (1) which and will cause it{him}. In the documentation on a site of system WebMoney the call is carried out with the help of function open2, however such variant works not always, therefore we will cause with the help of function system. We shall create the program (we shall name her{it} wschet.pl):</p>
<p>*!/usr/bin/perl</p>
<p>sub dopprobelz * function of addition of a line in zero in the beginning</p>
<p>{my ($str) = _ [0];</p>
<p>my ($len) = _ [1]; my $delta = $ len-length ($str);</p>
<p>my $hwost = &#8220;;</p>
<p>for (my ($a) =0; $a &lt;$delta; $a ++) {$hwost = $ hwost. &#8216; 0 &#8216;;};</p>
<p>$str = $ hwost. $ str; return $str;</p>
<p>};</p>
<p>* Connection of modules</p>
<p>use FileHandle;</p>
<p>use IPC:: Open2;</p>
<p>use CGI;</p>
<p>use Socket;</p>
<p>use LWP:: UserAgent;</p>
<p>* The task of parameters of search</p>
<p>* Here specify the data</p>
<p>$OrderID = &#8216; 999 &#8216;; * number{room} of the bill on your site</p>
<p>$PurseOfStores = &#8216; Z406593169293 &#8216;; * a purse of a site</p>
<p>$LoginOfStores = &#8216; 321373645120 &#8216;; * WMID a site</p>
<p>$LoginOfCust = &#8216; 083872782699 &#8216;; * WMID the buyer, we shall set as a constant</p>
<p>$InvAddress = &#8216; INVADDRESS &#8216;; * the address</p>
<p>$Amount = &#8216; 10 &#8216;; *????? bills which the buyer should pay</p>
<p>$Desc = &#8216; DESC &#8216;; * the description</p>
<p>$Period = &#8216; 0 &#8216;; *??«¬ the patronage of the transaction</p>
<p>$Experation = &#8216; 3 &#8216;; *??«¬ actions of the bill &#8211; 3 days</p>
<p>($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =localtime (time ());</p>
<p>$RequestN = (1900 + $ year) .dopprobelz ($mon, 2);</p>
<p>$RequestN = $ RequestN.dopprobelz ($mday, 2) .dopprobelz ($hour, 2);</p>
<p>$RequestN = $ RequestN.dopprobelz ($min, 2) .dopprobelz ($sec, 2) .dopprobelz ($sec, 2);</p>
<p>$PlanStr = &#8221; $ OrderID$LoginOfCust$PurseOfStores$Amount &#8220;;</p>
<p>$PlanStr = $ PlanStr. &#8221; $ Desc$InvAddress$Period$Experation$RequestN &#8220;;</p>
<p>print &#8221; Content-Type: text/html\n\n &#8220;;</p>
<p>print &#8221; the Line of the signature \ $PlanStr: $PlanStr &lt;br&gt; &lt;br&gt; &lt;br&gt; &#8220;;</p>
<p>* A call of module WMSigner</p>
<p>pipe (IN, OUT); * creation of a liaison channel (you write in OUT, you read from IN)</p>
<p>OUT-&gt; autoflush (1);</p>
<p>$pid = open (CHILD, &#8221; | &#8211; &#8220;); * division into 2 processes</p>
<p>*??n??????? input doch. Percents with descriptor CHILD</p>
<p>if ($pid! = 0) {** if the given stream &#8211; the parent</p>
<p>close (OUT); * for Parent OUT it is not necessary, will write through CHILD</p>
<p>print CHILD $PlanStr. &#8220;\004\r\n &#8220;; * transfer of parameters to the descendant</p>
<p>close (CHILD); * transfer is finished, the descriptor is not necessary</p>
<p>$SignStr = $_ while (&lt;IN&gt;); * Data acquisition from a clone</p>
<p>close (IN);</p>
<p>waitpid ($pid, 0);</p>
<p>} else {**** if a clone (descendant)</p>
<p>close (IN);</p>
<p>open (STDOUT, &#8220;&gt; and =OUT &#8220;); * replacement of a standard conclusion on deskr. OUT</p>
<p>close (OUT);</p>
<p>system (&#8216;./wmsigner &#8216;); * start of module WMSigner (will return the data in OUT)</p>
<p>exit;};</p>
<p>print &#8221; the Digital signature (it is returned WMSigner \&#8217;om): $SignStr &lt;br&gt; &lt;br&gt; &lt;br&gt; &#8220;;</p>
<p>$W3sUrl = &#8221; https: // w3s.webmoney.ru/asp/Invoice.asp? SL = $ LoginOfStores and &#8220;;</p>
<p>$W3sUrl = $ W3sUrl. &#8221; SP = $ PurseOfStores*CL = $ LoginOfCust*IN = $ OrderID*D = $ Desc and &#8220;;</p>
<p>$W3sUrl = $ W3sUrl. &#8221; AD = $ InvAddress*A = $ Amount*E = $ Experation*P = $ Period and &#8220;;</p>
<p>$W3sUrl = $ W3sUrl. &#8221; RN = $ RequestN*SS = $ SignStr &#8220;;</p>
<p>print &#8221; HTTPS search to system: &lt;br&gt; &#8220;. $W3sUrl. &#8221; &lt;br&gt; &lt;br&gt; &lt;br&gt; &#8220;;</p>
<p>$ua2 = LWP:: UserAgent-&gt; new;</p>
<p>$res2 = $ ua2-&gt; get ($W3sUrl);</p>
<p>$buf = $ res2-&gt; content;</p>
<p>print &#8221; the Answer of system: &lt;br&gt; &#8220;. $buf;</p>
<p>* Further it is necessary to make analysis of the buffer and recording of the bill for a database of shop</p>
<p>To this program it is necessary to put in a folder the compiled module WMSigner (access rights 711), a backup copy of keys (at start Keeper will request to create a backup copy kjuchej and to set the password for this copy, after creation copy a file *.kwm on a site to the program wschet.pl and rename it{him} in keys.kwm, expose to him access rights 440) and a file wmsigner.ini (access rights 440) following maintenance{contents}:</p>
<p>WMID</p>
<p>pass</p>
<p>./keys.kwm</p>
<p>Where WMID &#8211; the identifier of shop, pass &#8211; the password from a backup copy of keys./keys.kwm &#8211; a way to a file of keys.</p>
<p>Now we shall in details disassemble a way of start of the module wmsigner from our program. For a call of the module function system () which connects streams of input-output of caused process with streams VV of the program causing process is used, that is the data transferred{handed} to the causing program from the outside will receive and started system () process and the data returned by process will be deduced{removed} by function there, where also the data of the causing program (in our case in a browser of the user that is undesirable). For division of streams VV our program all over again creates a clone, then this clone causes process WMSigner and obtains from him{it} the data, and the basic program obtains the data already from the clone, process of creation of a clone and redefinition of his{its} standard descriptor of input on CHILD is realized with the help of function $pid = open (CHILD, &#8221; | &#8211; &#8220;).</p>
<p>If the module will give out a mistake-3, know, that in wmsigner.ini you have specified the password not from a backup copy of keys or have copied not a backup copy of keys.</p>
<p>That&#8217;s all, now it is necessary to adapt only signs under the problem{task}, and in following clause{article} I shall tell as to organize check, whether the bill has been paid.</p>
]]></content:encoded>
			<wfw:commentRss>http://novices-design-courses.info/program-extract-of-the-bill-in-system-webmoney/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even about protection e-mail addresses on webs &#8211; pages</title>
		<link>http://novices-design-courses.info/even-about-protection-e-mail-addresses-on-webs-pages/</link>
		<comments>http://novices-design-courses.info/even-about-protection-e-mail-addresses-on-webs-pages/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 07:01:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[protection e-mail addresses]]></category>

		<guid isPermaLink="false">http://novices-design-courses.info/?p=61</guid>
		<description><![CDATA[About protection e-mail addresses from scanning by spams &#8211; robots in the Internet it was written much. More likely on the contrary, it is a lot of. However all the ways long are reduced basically to one &#8211; coding of addresses so that spams &#8211; robots could not distinguish it{him}, and for the person it [...]]]></description>
			<content:encoded><![CDATA[<p>About protection e-mail addresses from scanning by spams &#8211; robots in the Internet it was written much. More likely on the contrary, it is a lot of. However all the ways long are reduced basically to one &#8211; coding of addresses so that spams &#8211; robots could not distinguish it{him}, and for the person it is possible. More often to me there were such variants: name [at] server.ru, name (a) server.ru and even name (Shift+2) server.ru. A variant, certainly, too good, but spams &#8211; robots quickly &#8220;study&#8221;. <span id="more-61"></span>About protection e-mail addresses from scanning by spams &#8211; robots in the Internet it was written much. More likely on the contrary, it is a lot of. However all the ways long are reduced basically to one &#8211; coding of addresses so that spams &#8211; robots could not distinguish it{him}, and for the person it is possible. More often to me there were such variants: name [at] server.ru, name (a) server.ru and even name (Shift+2) server.ru. A variant, certainly, too good, but spams &#8211; robots quickly &#8220;study&#8221;. The skilled Internet serfer will guess, that [at] it is necessary to replace on, but some people copy name [at server.ru address directly in a mailer, and then are surprised - why letters do not reach:) In the beginning the problem of a spam not so disturbed me while once mountains of advertising letters did not fall down on my box. The same day has found a simple output{exit}: "sobachku" it is possible to show as a picture, all rest - as symbols. Externally - usual e-mail and to copy will fail.</p>
<p>I bring to your attention a simple and accessible way of the publication e-mail addresses without fear, that it{he} will be scanned with the spam - robot. Though, probably, also will scan, but for this purpose he should possess an artificial intellect:) Requirements: presence PHP with library GD. Many likely have guessed, that we shall do{make} with addresses. We … shall draw them! We shall name our script email.php. The algorithm is simple enough:</p>
<p>1. One of ways the script receives on an input{entrance} ?-mail the address:</p>
<p>1. We shall receive the address of the author from a database, having specified for example id clauses{articles} or recordings in the guest book (the catalogue of files, links, etc.).</p>
<p>2. We shall pass the address to a script in an obvious kind: email. php? adr=name@server.ru (but it is fraught with that, that e-mail all "is lighted"). Such protection is equivalent her{it} otsutsviju.</p>
<p>3. We shall pass the address to a script in an implicit kind: email. php? name=name*server=server. ru</p>
<p>4. We shall pass the address to a script in the ciphered kind: email.php? adr=anzr@freire.eh (having used function str_rot13 () which displaces codes of all latin letters upwards on 13).</p>
<p>2. The script deciphers the data, generates a picture with the image of the address and returns to its{her} browser.</p>
<p>For the beginning we shall consider process of "drawing" as he subsequently remain constant:</p>
<p>$size = 2;</p>
<p>$im = imagecreate (imagefontwidth ($size) *strlen ($adr), imagefontheight ($size));</p>
<p>Here there is nothing especial. The initial data: $adr - the address which should "be drawn", $size - the size of a font in a picture (it is easily selected on the size and "fat content", is externally similar on Tahoma, Verdana, Arial). Function imagecreate () creates a picture and places the index on it{her} in a variable $im. However for this purpose we shall calculate the sizes of the future picture, proceeding from the size of a font and quantity{amount} of symbols in line.</p>
<p>imagefontwidth ($size) - defines{determines} width of one symbol at the size $size. We shall increase her{it} for length of a line strlen ($adr) and we shall receive width of the future picture. The height of a picture is calculated by function imagefontheight ($size). We add in a palette of the image of color of a background and an inscription (accordingly white and red)</p>
<p>$bg = imagecolorallocate ($im, 255, 255, 255);</p>
<p>$black = imagecolorallocate ($im, 0x00, 0x00, 0x00);</p>
<p>If color of a background of your site not white, we shall make so:</p>
<p>imagecolortransparent ($im, $bg);</p>
<p>Color $bg in a palette becomes transparent, therefore $bg can be any color. Color of symbols is set according to your needs{requirements}.</p>
<p>We do{make} an inscription:</p>
<p>imagestring ($im, $size, 0, 0, $adr, $black);</p>
<p>Also we deduce{remove} a picture:</p>
<p>header (' Content-type: image/png ');</p>
<p>imagepng ($im);</p>
<p>Now we shall consider, in what ways it is possible to receive e-mail for processing. In the table variants of addressing and corresponding fragments of a code are placed.</p>
<p>Extraction e-mail from database MySQL.</p>
<p>email.php? id=1</p>
<p>mysql_connect ("localhost", "username", "password");</p>
<p>mysql_select_db ("database");</p>
<p>$id = abs (intval ($id));</p>
<p>$query = " SELECT email FROM table WHERE table_id = ' $ id ' ";</p>
<p>$result = mysql_query ($query);</p>
<p>$f = mysql_fetch_array ($result);</p>
<p>if (empty ($f [email])) $adr = &#8220;n/a&#8221;;</p>
<p>else $adr = $f [email];</p>
<p>Direct transfer of the address</p>
<p>email. php? adr=name@server.ru</p>
<p>The additional code is not necessary</p>
<p>Separate transfer of the address</p>
<p>email.php? name=name and</p>
<p>server=server.ru</p>
<p>$adr = $name.. $ server</p>
<p>Transfer of the coded address</p>
<p>email. php? adr=anzr@freire.eh</p>
<p>(the address has been coded by function str_ rot13 (), she will decode it{him}, because letters in the latin alphabet only 26, and displacement each time on 13)</p>
<p>$adr = str_rot13 ($adr);</p>
<p>All script entirely (add the way of reception of the address necessary to you):</p>
<p>&lt;? php</p>
<p>$size = 2;</p>
<p>$im = imagecreate (imagefontwidth ($size) *strlen ($adr), imagefontheight ($size));</p>
<p>$bg = imagecolorallocate ($im, 255, 255, 255);</p>
<p>$black = imagecolorallocate ($im, 0&#215;00, 0&#215;00, 0&#215;00);</p>
<p>imagecolortransparent ($im, $bg);</p>
<p>imagestring ($im, $size, 0, 0, $adr, $black);</p>
<p>header (&#8216; Content-type: image/png &#8216;);</p>
<p>imagepng ($im);</p>
<p>?&gt;</p>
<p>The conclusion of a picture instead of real e-mail is done{made} approximately so:</p>
<p>Yours e-mail: &lt;a href = &#8220;mailto:name@server.ru&#8221;&gt; name@server.ru &lt;/a&gt;</p>
<p>Yours e-mail: &lt;img src = &#8221; email.php? adr=name@server.ru &#8220;&gt;</p>
<p>Now, when we know how to replace e-mail addresses, it is possible to write function which will make such replacements in the set text by means of regular expressions. It can be demanded at total kill of all conclusion, batch operation of HTML-files, a conclusion of the information from a DB.</p>
<p>Let&#8217;s divide{share} the address into 3 parts:</p>
<p>(Name) (Domain). (Zone)</p>
<p>And that already we have a pattern of type:</p>
<p>(. *) (. *). (. *)</p>
<p>Under this formula billions expressions will approach, but we go further under the specification e-mail addresses. The login name should consist from &#8220;a-z&#8221;, &#8220;A-Z&#8221;, &#8220;0-9&#8243;, and also &#8220;.&#8221;, &#8220;_&#8221; and &#8220;-&#8221;. If not I am mistaken, strict rules in this occasion never was, also other symbols somewhere are resolved{allowed}, it is a basis. &#8220;A-Z&#8221; it is added on a case if the user likes to register the soap &#8220;more abruptly&#8221;. Length of a name from 2 up to 256-ti symbols (see RFC). Further the domain, too most &#8211; &#8220;a-z&#8221;, &#8220;A-Z&#8221;, &#8220;0-9&#8243;, &#8220;.&#8221;, &#8220;-&#8221; and all! The length of a domain name the same, unique difficulty &#8211; if a soap is not in the domain of the second level, and, say, the third or even the fourth. Here again in RFC to be thrown it is necessary, as also service DNS is not deprived &#8220;answer&#8221; such as HTTP 414:). The length of the domain cannot exceed 256 symbols, but whether subdomains enter into this number &#8211; I do not remember. A zone &#8211; here it is simple &#8220;a-z&#8221;, &#8220;A-Z&#8221; from 2 up to 4 symbols.</p>
<p>In a result something turns out such:</p>
<p>([a-zA-Z0-9 |. |-| _] {2,256}) (([a-zA-Z0-9 |. |-] {2,256}). ([a-z] {2,4}))</p>
<p>It is possible to check up, whether begin (or come to an end) podvyrazhenija \1, \2 symbols of type &#8220;.&#8221; Or &#8220;-&#8221;, is farther &#8211; on what the imagination suffices. Using the calculated regular expression (lectures on matanalizu are involuntarily recollected), we shall write function which will replace all e-mail addresses in line with tag IMG and to return the changed line. As function of replacement I used preg_replace () with syntax Perl RegExp.</p>
<p>email_ replace. php</p>
<p>&lt;? php</p>
<p>// Function of replacement e-mail addresses</p>
<p>function email_replace ($text)</p>
<p>{</p>
<p>$exp = &#8216; / ([a-zA-Z0-9 |. |-| _] {2,256}) (([a-zA-Z0-9 |. |-] {2,256}). ([a-z] {2,4})) / &#8216;;</p>
<p>return preg_replace ($exp, &#8216; &lt;img src=email.php? name =\1*server =\2 border=0&gt; &#8216;, $text);</p>
<p>}</p>
<p>// An initial line with set e-mail addresses</p>
<p>$text = &lt;&lt;&lt;END</p>
<p>On all questions write on mine e-mail:</p>
<p>f_mulder@list.ru,</p>
<p>fox58@list.ru,</p>
<p>admin@foxweb.net.ru,</p>
<p>kurepin@sura.ru,</p>
<p>fox58@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com</p>
<p>(it is the real address!!!) &#8220;;</p>
<p>END;</p>
<p>echo $text; // an initial line</p>
<p>echo &#8220;&lt;br&gt;&#8221;;</p>
<p>echo email_replace ($text); // the changed line</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://novices-design-courses.info/even-about-protection-e-mail-addresses-on-webs-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing HTTPS URLs</title>
		<link>http://novices-design-courses.info/accessing-https-urls/</link>
		<comments>http://novices-design-courses.info/accessing-https-urls/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:45:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://novices-design-courses.info/?p=22</guid>
		<description><![CDATA[When you want to get access to page through HTTPS all will work as well as in case we would deal ordinary HTTP with the report if you LWP has support HTTPS (through corresponding Secure Sockets Layer library).

When you want to get access to page through HTTPS all will work as well as in case [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to get access to page through HTTPS all will work as well as in case we would deal ordinary HTTP with the report if you LWP has support HTTPS (through corresponding Secure Sockets Layer library).</p>
<p><span id="more-22"></span></p>
<p>When you want to get access to page through HTTPS all will work as well as in case we would deal ordinary HTTP with the report if you LWP has support HTTPS (through corresponding Secure Sockets Layer library). For example:</p>
<p>use LWP 5.64;</p>
<p>my $url = &#8216; https: // www.paypal.com / &#8216;; * Yes, HTTPS!</p>
<p>my $browser = LWP:: UserAgent-&gt; new;</p>
<p>my $response = $browser-&gt; get ($url);</p>
<p>die &#8221; Error at $urln &#8220;, $response-&gt; status_line, &#8221; n Aborting &#8221;</p>
<p>unless $response-&gt; is_success;</p>
<p>print &#8221; Whee, it worked! I got that &#8220;,</p>
<p>$response-&gt; content_type, &#8221; document! n &#8220;;</p>
<p>If you LWP has no support HTTPS then the answer will be not successful and you receive the following mistake:</p>
<p>Error at https: // www.paypal.com/</p>
<p>501 Protocol scheme &#8216; https &#8216; is not supported</p>
<p>Aborting at paypal.pl line 7. [or whatever program and line]</p>
<p>If you LWP has support HTTPS then the answer should be successful, and you should fulfil with $response as well as with kljubym the ordinary HTTP-answer.</p>
<p>For reception of the information on installation of support HTTPS for LWP read file README.SSL which is included into the distribution kit libwww-perl.</p>
<p>Reception of the big documents</p>
<p>When you request big (or potentially big) the document, arises a problem with standard actions with methods of searches (it is similar $response = $browser-&gt; get ($url)) with that, that all object of the answer should be stored{kept} in memory. If the answer is 30-megabajtnyj a file it, to put it mildly, is not so good for your operative memory and the size of your process in her.</p>
<p>Good alternative is preservation of a file on a disk, instead of in memory. Syntax the following:</p>
<p>$response = $ua-&gt; get ($url,</p>
<p>&#8216;:content_file &#8216; =&gt; $filespec,</p>
<p>);</p>
<p>For example,</p>
<p>$response = $ua-&gt; get (&#8216; http: // search.cpan.org / &#8216;,</p>
<p>&#8216;:content_file &#8216; =&gt; &#8216;/tmp/sco.html &#8216;</p>
<p>);</p>
<p>When you use opciju:content_file, the object $response will have all normal headings, however $response-&gt; content will be empty.</p>
<p>I shall note, that the option &#8220;:content_file&#8221; was not supported by old versions LWP, therefore you should take it into consideration, having added use LWP 5.66; for check of version LWP if you consider, that your program can be started on systems with older versions LWP.</p>
<p>If you want, that the program has been compatible with older versions LWP then use syntax which allows to make too most:</p>
<p>use HTTP::Request::Common;</p>
<p>$response = $ua-&gt; request (GET ($url), $filespec);</p>
<p>[HTML] &lt;h3&gt; Links &lt;/h3&gt; [/HTM]</p>
<p>Remember, that this clause{article} is only the very first introduction in LWP &#8211; for deeper studying LWP and the problems{tasks} connected with LWP, you should read the following materials:</p>
<p>*</p>
<p>LWP:: Simple: simple functions for uploading, rabora zagovkov and mirrorings of addresses.</p>
<p>*</p>
<p>LWP: the Review of modules libwww-perl.</p>
<p>*</p>
<p>LWP:: UserAgent: the Class for objects which play a role of &#8221; virtual browsers &#8220;.</p>
<p>*</p>
<p>HTTP::Response: the Class of objects which represent &#8220;answer&#8221;, such as in $response = $browser-&gt; get (&#8230;).</p>
<p>*</p>
<p>HTTP::Message and HTTP::Headers: Classes for granting a lot of methods for HTTP::Response.</p>
<p>*</p>
<p>URI: the Class for objects which represent absolute or relative URLy.</p>
<p>*</p>
<p>URI:: Escape: Functions for job with escape-sequences in addresses (for example transformation there and back from &#8221; this and that &#8221; v &#8220;this%20%26%20that&#8221;).</p>
<p>*</p>
<p>HTML:: Entities: Functions for job with escape-sequences in HTML (for example transformation there and back from &#8221; C. and E. Bront and * 235; &#8221; v &#8221; C. *amp; E. Bront*euml; &#8220;).</p>
<p>*</p>
<p>HTML:: TokeParser and HTML:: TreeBuilder: Classes for grammatic analysis (&#8220;parsing&#8221;) HTML.</p>
<p>*</p>
<p>HTML:: LinkExtor: the Class for a presence{finding} of links in documents.</p>
<p>*</p>
<p>And the last, but not the least, my book Perl and LWP.</p>
]]></content:encoded>
			<wfw:commentRss>http://novices-design-courses.info/accessing-https-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Bases with LWP</title>
		<link>http://novices-design-courses.info/web-bases-with-lwp/</link>
		<comments>http://novices-design-courses.info/web-bases-with-lwp/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:38:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Web Bases]]></category>

		<guid isPermaLink="false">http://novices-design-courses.info/?p=15</guid>
		<description><![CDATA[LWP (reduction from &#8221; Library for WWW in Perl &#8220;) is very popular group of modules of language Perl for a data access in network Internet. As well as the majority of modules of language Perl, on each module from structure LWP is present the documentation with the full description of his{its} interface. However, in [...]]]></description>
			<content:encoded><![CDATA[<p>LWP (reduction from &#8221; Library for WWW in Perl &#8220;) is very popular group of modules of language Perl for a data access in network Internet. As well as the majority of modules of language Perl, on each module from structure LWP is present the documentation with the full description of his{its} interface. However, in LWP there is a set of modules for which it is rather difficult to find the documentation on, apparently, elementary things.</p>
<p><span id="more-15"></span>LWP (reduction from &#8221; Library for WWW in Perl &#8220;) is very popular group of modules of language Perl for a data access in network Internet. As well as the majority of modules of language Perl, on each module from structure LWP is present the documentation with the full description of his{its} interface. However, in LWP there is a set of modules for which it is rather difficult to find the documentation on, apparently, elementary things.</p>
<p>Introduction in use LWP, obviously, should borrow{occupy} the whole book, &#8211; the book which only has come out of press, and named: Perl and LWP. This clause{article} offers you some examples which will help you with the organization of usual things with LWP.</p>
<p>Access to pages with help LWP:: Simple</p>
<p>If you only want to receive the document which is taking place to certain (URL address the most simple way to make it &#8211; to use functions of module LWP:: Simple.</p>
<p>In a Perl-script you can make it, having called function get ($url). She will try to extend contents of it URL. If all will fulfil normally function will return these contents; but if there will be any mistake she will return undef.</p>
<p>my $url = &#8216; http: // freshair.npr.org/dayFA.cfm? todayDate=current &#8216;;</p>
<p>* Only for an example: new recordings on/Fresh Air/</p>
<p>use LWP:: Simple;</p>
<p>my $content = get $url;</p>
<p>die &#8221; Couldn&#8217;t get $url &#8221; unless defined $content;</p>
<p>* Further something is done{made} with $content, for example:</p>
<p>if ($content = ~ m/jazz/i) {</p>
<p>print &#8221; They&#8217;re talking about jazz today on Fresh Air! n &#8220;;</p>
<p>} else {</p>
<p>print &#8221; Fresh Air is apparently jazzless today.n &#8220;;</p>
<p>}</p>
<p>More convenient variant of function get is getprint which is convenient for prostmotra sodarzhimogo pages through Perl. If function getprint can &#8220;get&#8221; a page, which address you have set, she sends contents in STDOUT; otherwise, in a role of the book of complaints acts STDERR.</p>
<p>% perl-MLWP:: Simple-e &#8221; getprint &#8216; http://cpan.org/RECENT &#8216; &#8221;</p>
<p>It URL a simple text file. He contains the list of new files on CPAN for last two weeks. You can easily make the shell-command which, for example, will send to you the list of new modules Acme:::</p>
<p>[] CODE</p>
<p>% perl-MLWP:: Simple-e &#8221; getprint &#8216; http://cpan.org/RECENT &#8216; &#8221;</p>
<p>| grep &#8220;/by-module/Acme&#8221; | mail-s &#8221; New Acme modules! Joy! &#8221; $USER</p>
<p>[/CODE]</p>
<p>In module LWP:: Simple exists still a little bit enough useful functions, including function for performance of HEAD-search for URL (it is useful to check of links or reception of date of last updating of the document) and two functions for preservation and mirrorings URL in a local file. Look the documentation on LWP:: Simple for more detailed information, or Chapter{Head} 2, &#8221; Web Bases &#8221; Perl and LWP for a lot of examples.</p>
<p>Bases of class model LWP</p>
<p>Functions LWP:: Simple are convenient only for simple cases, but these functions do not support shadow parcels{sendings} (further cookies) and authentications (further authorization); they also do not allow to establish any parameters HTTP of search; and the main thing, they do not allow to read out a line of heading in HTTP the answer (especially full text of the message in case HTTP of a mistake (HTTP error message)). For access to all these opportunities, you should use all set of classes LWP.</p>
<p>LWP contains set of classes, but main two which you should understand is LWP:: UserAgent and HTTP::Response. LWP:: UserAgent it is a class for &#8221; virtual browsers &#8220;, ktorymi you will use for performance of searches. HTTP::Response it is a class for answers (or messages on a mistake) which you receive back, after search.</p>
<p>The basic expression at job with LWP: $response = $browser-&gt; get ($url), or completely:</p>
<p>use LWP 5.64; * all Is loaded necessary LWP classes, and udostoverivaemsja</p>
<p>* In sufficient freshness of the version of the module.</p>
<p>my $browser = LWP:: UserAgent-&gt; new;</p>
<p>&#8230;</p>
<p>* That is used below, URL to which the search will be made:</p>
<p>my $url = &#8216; http: // freshair.npr.org/dayFA.cfm? todayDate=current &#8216;;</p>
<p>my $response = $browser-&gt; get ($url);</p>
<p>die &#8221; Can&#8217;t get $url &#8211; &#8220;, $response-&gt; status_line</p>
<p>unless $response-&gt; is_success;</p>
<p>die &#8221; Hey, I was expecting HTML, not &#8220;, $response-&gt; content_type</p>
<p>unless $response-&gt; content_type eq &#8216; text/html &#8216;;</p>
<p>* Or another content-type which approaches you</p>
<p>* Otherwise, we make processing contents:</p>
<p>if ($response-&gt; content = ~ m/jazz/i) {</p>
<p>print &#8221; They&#8217;re talking about jazz today on Fresh Air! n &#8220;;</p>
<p>} else {</p>
<p>print &#8221; Fresh Air is apparently jazzless today.n &#8220;;</p>
<p>}</p>
<p>In this example it has been switched on two objects, in comparison with the previous example: $browser which contains object of class LWP:: UserAgent, and object $response which of a class HTTP::Response. Usually it is necessary to you no more than one object $browser; but each time as you interpellate, you receive back new object HTTP::Response which contains some interesting methods:</p>
<p>*</p>
<p>Status code (the Code of a status) which shows success or failure of search (you it can check up so: $response-&gt; is_success).</p>
<p>*</p>
<p>HTTP status line (status bar) which, I think, will be pleased informative in case of a mistake (you can see her{it}, using $response-&gt; status_line, she returns something like: &#8221; 404 Not Found &#8220;).</p>
<p>*</p>
<p>MIME content-type, for example &#8220;text/html&#8221;, &#8220;image/gif&#8221;, &#8220;application/xml&#8221;, etc. which you can see, using $response-&gt; content_type</p>
<p>*</p>
<p>Actually contents of the required document in $response-&gt; content. In a case with HTML, here will be HTML a code; if &#8211; GIF $response-&gt; content will return binary data GIF.</p>
<p>*</p>
<p>And also set convenient and more specific which are described in the documentation on HTTP::Response, and to his{its} super classes, HTTP::Message and HTTP::Headers.</p>
<p>Addition of other headings HTTP of search</p>
<p>Most often used syntax for searches $response = $browser-&gt; get ($url), but, to tell the truth, you can add own lines HTTP of headings to search, addition of the list of pairs key &#8211; value after URL, for example:</p>
<p>$response = $browser-&gt; get ($url, $key1, $value1, $key2, $value2&#8230;);</p>
<p>Here is how to send Netscape-like headings:</p>
<p>my @ns_headers = (</p>
<p>&#8216; User-Agent &#8216; =&gt; &#8216; Mozilla/4.76 [en] (Win98; U) &#8216;,</p>
<p>&#8216;Accept&#8217; =&gt; &#8216; image/gif, image/x-xbitmap, image/jpeg,</p>
<p>image/pjpeg, image/png, */* &#8216;,</p>
<p>&#8216; Accept-Charset &#8216; =&gt; &#8216; iso-8859-1, *, utf-8 &#8216;,</p>
<p>&#8216; Accept-Language &#8216; =&gt; &#8216; en-US &#8216;,</p>
<p>);</p>
<p>&#8230;</p>
<p>$response = $browser-&gt; get ($url, @ns_headers);</p>
<p>If you will not use this file further, you can act{arrive} as follows:</p>
<p>$response = $browser-&gt; get ($url,</p>
<p>&#8216; User-Agent &#8216; =&gt; &#8216; Mozilla/4.76 [en] (Win98; U) &#8216;,</p>
<p>&#8216;Accept&#8217; =&gt; &#8216; image/gif, image/x-xbitmap, image/jpeg,</p>
<p>image/pjpeg, image/png, */* &#8216;,</p>
<p>&#8216; Accept-Charset &#8216; =&gt; &#8216; iso-8859-1, *, utf-8 &#8216;,</p>
<p>&#8216; Accept-Language &#8216; =&gt; &#8216; en-US &#8216;,</p>
<p>);</p>
<p>If you are going to to change only &#8216; User-Agent &#8216;-parameters, you can change standard installation of object $browser &#8220;libwww-perl/5.65&#8243; (or something similar) to all that you want, using a corresponding method of object LWP:: UserAgent:</p>
<p>$browser-&gt; agent (&#8216; Mozilla/4.76 [en] (Win98; U) &#8216;);</p>
<p>Inclusion Cookies (Shadow parcels{sendings})</p>
<p>Usually object LWP:: UserAgent works as a browser with the switched &#8211; off support cookies. There are some ways to switch on such support, using a method cookie_jar. &#8221; cookie jar &#8221; are an object which if it is possible so to say, personifies a small DB with all HTTP cookies about which the browser can know. &#8220;DB&#8221; can be saved on a disk (so works Netscape, using a file cookies.txt), or &#8220;to hang&#8221; in memory, thus all set cookies will be lost, as soon as the program will finish the job.</p>
<p>To create empty object cookie jar in memory, call cookie_jar a method as follows:</p>
<p>$browser-&gt; cookie_jar ({}};</p>
<p>To do{make} copies cookies in a file on a disk which will contain all set cookies with which the browser worked, after end of the program, call cookie_jar a method as follows:</p>
<p>use HTTP::Cookies;</p>
<p>$browser-&gt; cookie_jar (HTTP:: Cookies-&gt; new (</p>
<p>&#8216;file&#8217; =&gt; &#8216;/some/where/cookies.lwp &#8216;,</p>
<p>*??®? an exchange</p>
<p>&#8216; autosave &#8216; =&gt; 1,</p>
<p>*»« end whether to save a file</p>
<p>));</p>
<p>This file will be in specific format LWP. If you want to get access to cookies from yours Netscape-cookies a file, you can use the following method: HTTP::Cookies::Netscape:</p>
<p>use HTTP::Cookies;</p>
<p>$browser-&gt; cookie_jar (HTTP:: Cookies:: Netscape-&gt; new (</p>
<p>&#8216; file &#8216; =&gt; &#8216; c:/Program Files/Netscape/Users/DIR-NAME-HERE/cookies.txt &#8216;,</p>
<p>* Whence to read kuki</p>
<p>));</p>
<p>You can add a line &#8216; autosave &#8216; =&gt; 1 as we did{made} earlier, but at the moment of recording there is a probability of that Netscape can give up in recording the some people cookies back on a disk.</p>
<p>Sending of the given forms by method POST</p>
<p>Many HTML forms send the data on the server, using search HTTP POST which you can carry out as follows:</p>
<p>$response = $browser-&gt; post ($url,</p>
<p>[</p>
<p>formkey1 =&gt; value1,</p>
<p>formkey2 =&gt; value2,</p>
<p>...</p>
<p>],</p>
<p>);</p>
<p>Or, if you need to send HTTP headings:</p>
<p>$response = $browser-&gt; post ($url,</p>
<p>[</p>
<p>formkey1 =&gt; value1,</p>
<p>formkey2 =&gt; value2,</p>
<p>...</p>
<p>],</p>
<p>headerkey1 =&gt; value1,</p>
<p>headerkey2 =&gt; value2,</p>
<p>);</p>
<p>For example, the following program carries out search search on AltaVista (sending of some given forms, using method HTTP POST), and takes quantity{amount} of concurrences from the test of the answer:</p>
<p>use strict;</p>
<p>use warnings;</p>
<p>use LWP 5.64;</p>
<p>my $browser = LWP:: UserAgent-&gt; new;</p>
<p>my $word = &#8216; tarragon &#8216;;</p>
<p>my $url = &#8216; http: // www.altavista.com/sites/search/web &#8216;;</p>
<p>my $response = $browser-&gt; post ($url,</p>
<p>[' q ' =&gt; $word, *»«??¬«??n a phrase</p>
<p>' pg ' =&gt; ' q ',' avkw ' =&gt; ' tgz ',' kl ' =&gt; ' XX ',</p>
<p>]</p>
<p>);</p>
<p>die &#8221; $url error: &#8220;, $response-&gt; status_line</p>
<p>unless $response-&gt; is_success;</p>
<p>die &#8221; Weird content type at $url &#8211; &#8220;, $response-&gt; content_type</p>
<p>unless $response-&gt; content_type eq &#8216; text/html &#8216;;</p>
<p>if ($response-&gt; content = ~ m {AltaVista found ([0-9,] +) results}) {</p>
<p>*?«????«¬? will be a kind: &#8221; AltaVista found 2,345 results &#8221;</p>
<p>print &#8221; $word: $1n &#8220;;</p>
<p>} else {</p>
<p>print &#8221; Couldn&#8217;t find the match-string in the responsen &#8220;;</p>
<p>}</p>
<p>Data transfer of forms by method GET</p>
<p>HTML forms pass the some people given not sending by method POST, and fulfilment ordinary GET search with the certain data set in end URL. For example, if you will go on imdb.com and start search on phrase Blade Runner URL which you will see, will be the following:</p>
<p>http: // us.imdb.com/Tsearch? title=Blade%20Runner*restrict=Movies+and+TV</p>
<p>For start of such search with help LWP, it is necessary to make the following:</p>
<p>use URI;</p>
<p>my $url = URI-&gt; new (&#8216; http://us.imdb.com/Tsearch &#8216;);</p>
<p>* Creates the object representing URL</p>
<p>$url-&gt; query_form (* Here pairs a key =&gt; value:</p>
<p>&#8216; title &#8216; =&gt; &#8216; Blade Runner &#8216;,</p>
<p>&#8216; restrict &#8216; =&gt; &#8216; Movies and TV &#8216;,</p>
<p>);</p>
<p>my $response = $browser-&gt; get ($url);</p>
<p>Look Chapter{Head} 2, &#8220;Forms&#8221; of book Perl and LWP for more detailed studying HTML of forms, as well as the chapter{head} with the sixth on the ninth for detailed studying extraction of the data from HTML.</p>
]]></content:encoded>
			<wfw:commentRss>http://novices-design-courses.info/web-bases-with-lwp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transformation relative in absoljutye links</title>
		<link>http://novices-design-courses.info/transformation-relative-in-absoljutye-links/</link>
		<comments>http://novices-design-courses.info/transformation-relative-in-absoljutye-links/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:07:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://novices-design-courses.info/?p=10</guid>
		<description><![CDATA[URI a class which we have considered just, the set of every possible functions for job with various parts URL gives (such as definition such as URL &#8211; $url-&#62; scheme, definition on what host he refers &#8211; $url-&#62; host, and so on on the basis of the documentation on classes URI.

URI a class which we [...]]]></description>
			<content:encoded><![CDATA[<p>URI a class which we have considered just, the set of every possible functions for job with various parts URL gives (such as definition such as URL &#8211; $url-&gt; scheme, definition on what host he refers &#8211; $url-&gt; host, and so on on the basis of the documentation on classes URI.</p>
<p><span id="more-10"></span></p>
<p>URI a class which we have considered just, the set of every possible functions for job with various parts URL gives (such as definition such as URL &#8211; $url-&gt; scheme, definition on what host he refers &#8211; $url-&gt; host, and so on on the basis of the documentation on classes URI. Nevertheless, the most interesting are a method query_form, considered earlier, and now a method new_abs for transformation of the relative link (&#8220;../foo.html&#8221;) in absolute (&#8221; http: // www.perl.com/stuff/foo.html &#8220;):</p>
<p>use URI;</p>
<p>$abs = URI-&gt; new_abs ($maybe_relative, $base);</p>
<p>For example, we shall consider this programmku which chooses links from a HTML-page snovymi modules on CPAN:</p>
<p>use strict;</p>
<p>use warnings;</p>
<p>use LWP 5.64;</p>
<p>my $browser = LWP:: UserAgent-&gt; new;</p>
<p>my $url = &#8216; http: // www.cpan.org/RECENT.html &#8216;;</p>
<p>my $response = $browser-&gt; get ($url);</p>
<p>die &#8221; Can&#8217;t get $url &#8211; &#8220;, $response-&gt; status_line</p>
<p>unless $response-&gt; is_success;</p>
<p>my $html = $response-&gt; content;</p>
<p>while ($html = ~ m / &lt;A HREF = &#8221; (. *?) &#8220;/g) {</p>
<p>print &#8220;$1n&#8221;;</p>
<p>}</p>
<p>At start she starts to give out something like it:</p>
<p>MIRRORING.FROM</p>
<p>RECENT</p>
<p>RECENT.html</p>
<p>authors/00whois.html</p>
<p>authors/01mailrc.txt.gz</p>
<p>authors/id/A/AA/AASSAD/CHECKSUMS</p>
<p>&#8230;</p>
<p>But, if you want receive the list of absolute links you can to use a method new_abs, having changed a cycle while as follows:</p>
<p>while ($html = ~ m / &lt;A HREF = &#8221; (. *?) &#8220;/g) {</p>
<p>print URI-&gt; new_abs ($1, $response-&gt; base), &#8220;n&#8221;;</p>
<p>}</p>
<p>($response-&gt; base the module HTTP::Message it is used for definition of the base address for transformation of relative links in absolute.)</p>
<p>Now our program gives out that ndo:</p>
<p>http://www.cpan.org/MIRRORING.FROM</p>
<p>http://www.cpan.org/RECENT</p>
<p>http://www.cpan.org/RECENT.html</p>
<p>http://www.cpan.org/authors/00whois.html</p>
<p>http://www.cpan.org/authors/01mailrc.txt.gz</p>
<p>http://www.cpan.org/authors/id/A/AA/AASSAD/CHECKSUMS</p>
<p>&#8230;</p>
<p>See. Chapter{head} 4, &#8220;URLs&#8221;, books Perl and LWP for the greater information on objects URI.</p>
<p>Certainly, use regexp for allocation of addresses is too prmitivnym a method, therefore for more serious programs it is necessary to use modules of &#8221; grammatic analysis HTML &#8221; similar HTML:: LinkExtor or HTML:: TokeParser, or, even can be, HTML:: TreeBuilder.</p>
<p>Other properties of a browser</p>
<p>Objects LWP:: UserAgent have set svojst for management of own job. Some from them:</p>
<p>*</p>
<p>$browser-&gt; timeout (15): This method establishes a maximum quantity of time for expectation of the answer of the server. If after 15 seconds (in this case) it will not be received the answer the browser will stop search.</p>
<p>*</p>
<p>$browser-&gt; protocols_allowed ([' http ',' gopher ']): types of links with which the browser will &#8220;communicate&#8221; Are established., in particular HTTP and gopher. If there will be osuhhestvena an attempt to get access to any document under other report (for example, &#8221; ftp: &#8220;, &#8221; mailto: &#8220;, &#8221; news: &#8220;) there will be no even an attempt of connection, and we shall receive a mistake 500, with the message similar: &#8221; Access to ftp URIs has been disabled &#8220;.</p>
<p>*</p>
<p>use LWP:: ConnCache;</p>
<p>$browser-&gt; conn_cache (LWP:: ConnCache-&gt; new ()): After this installation the object of a browser tries to use HTTP/1.1 &#8220;Keep-Alive&#8221; which accelerates searches by use of one connection for several searches to the same server.</p>
<p>*</p>
<p>$browser-&gt; agent (&#8216; SomeName/1.23 (more info here maybe) &#8216;): we Determine as our browser will identify myself in line &#8220;User-Agent&#8221; HTTP searches. By default, he sends &#8220;libwww-perl/versionnumber&#8221;, i.e. &#8220;libwww-perl/5.65&#8243;. You can change it to more informative message:</p>
<p>$browser-&gt; agent (&#8216; SomeName/3.14 (contact@robotplexus.int) &#8216;);</p>
<p>Or, if it is necessary, you can will pretend to be a real browser:</p>
<p>$browser-&gt; agent (</p>
<p>&#8216; Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC) &#8216;);</p>
<p>*</p>
<p>push {$ua-&gt; requests_redirectable}, &#8216; POST &#8216;: we Establish{Install} our browser on carrying out readdressing on POST searches (so does{makes} the majority of modern browsers (IE, NN, Opera)) though HTTP RFC speaks us about that, what is it generally it should not be carried out.</p>
]]></content:encoded>
			<wfw:commentRss>http://novices-design-courses.info/transformation-relative-in-absoljutye-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
