Jump to content

Strings...


Recommended Posts

Hi , i want copy from site like: pytajnia.pl or google.pl name of website.

In html code is inside <title></title>.... How copy it?

this under not working :(

Func Spis()
$oie=_IECreate("http://www.pytajnia.pl/dzial/pytania/pokaz/"&$x&"/antyban.pl",0,0,0,0)
_IELoadWait($oie)
x = 1337
$html=_IEBodyReadHTML($oie)

$betwen=_StringBetween($html,'<head>','</head>')

For $y=0 to UBound($betwen)-1
$trim=StringTrimLeft($betwen[$y],5)
$replace=StringReplace($trim,"-"," ")
FileWriteline("pytania_spisane2.txt", $replace&@CRLF)

$sSource = $html

$sExtract = StringRegExpReplace($sSource, ".*<head>(.*)</head>.*", "$1")

ConsoleWrite($sExtract & @CRLF)
Next
_IEQuit($oie)
$file=FileRead("pytania_spisane2.txt")
sleep(3000)
Spis()
EndFunc

And someone can tell me when function working 20 seconds inside alt+ctrl+del window i se 100x iexprolers?

Edited by koszmail2
Link to comment
Share on other sites

Hi , i want copy from site like: pytajnia.pl or google.pl name of website.

In html code is inside <title></title>.... How copy it?

this under not working :(

Func Spis()
$oie=_IECreate("http://www.pytajnia.pl/dzial/pytania/pokaz/"&$x&"/antyban.pl",0,0,0,0)
_IELoadWait($oie)
x = 1337
$html=_IEBodyReadHTML($oie)

$betwen=_StringBetween($html,'<head>','</head>')

For $y=0 to UBound($betwen)-1
$trim=StringTrimLeft($betwen[$y],5)
$replace=StringReplace($trim,"-"," ")
FileWriteline("pytania_spisane2.txt", $replace&@CRLF)

$sSource = $html

$sExtract = StringRegExpReplace($sSource, ".*<head>(.*)</head>.*", "$1")

ConsoleWrite($sExtract & @CRLF)
Next
_IEQuit($oie)
$file=FileRead("pytania_spisane2.txt")
sleep(3000)
Spis()
EndFunc

And someone can tell me when function working 20 seconds inside alt+ctrl+del window i se 100x iexprolers?

Hello! Why are you calling this recursivly? Im pretty sure this would just go forever?

$file=FileRead("pytania_spisane2.txt")
sleep(3000)
Spis() <------------------- ???
EndFunc

And do you mean between <head>? not <Title>?

Link to comment
Share on other sites

Your problem is that your function is needlessly calling itself over and over again, it's going to crash the script eventually.

Plus, what isn't working as you're expecting it to? Because you're not explaining well what isn't working, and what you want to do with the information from the page.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Trolling? Right.. Anyway. You shouldnt be calling the function from within the function. That will create a endless loop. No where in the code are you searching for string between <title></title> so thats why I ask.

Link to comment
Share on other sites

Trolling? Right.. Anyway. You shouldnt be calling the function from within the function. That will create a endless loop. No where in the code are you searching for string between <title></title> so thats why I ask.

Right, but even i tryed to put <title> where are <head> now. You should know it. I have last post.

http://pl.twitch.tv/czarnybaras

I need put inside pause script anyway.

Ok. Script should generate link > check link > and copy title/head/meta

For what? Just trying some tricks. And anyway, i try a lot things with this dramma function "Stringsbetwen" and not working anyway. Just givme a lesson Sir.

Link to comment
Share on other sites

Well the example is incomplete. For an example just post a direct link. Break it down to the exact spot that your script stops working. Also it you have direct links and the web site does not require a log in, I alway use _inetgetsource. Makes it alot simpler. So here we go. This assumes the link is http://www.pytajnia.pl/dzial/pytania/pokaz/1337/antyban.pl

#include <Inet.au3>
#include <String.au3>

$x = 1337
$link = 'http://www.pytajnia.pl/dzial/pytania/pokaz/' & $x & '/antyban.pl'
$source = _INetGetSource($link)
$aTitle = _StringBetween($source, '<title>', '</title>')
ConsoleWrite($aTitle[0] & @LF)

Output: Pytajnia.pl - Pytanie do chÅ‚opakÃ&sup3;w.

Edited by Beege
Link to comment
Share on other sites

How this should work with this code html:

<a href="/pyt/23204/XXJJE/jak-sciagnac-fotoszopa">Jak ściągnąć fotoszopa??</a>

The 23204 and XXJJE are random. Things what i need from this code with underline.

XXJJE + Jak ściągnąć fotoszopa??

Edited by koszmail2
Link to comment
Share on other sites

This should pull them out

$sHTML = '<a href="/pyt/23204/XXJJE/jak-sciagnac-fotoszopa">Jak sciagnac fotoszopa??</a>'
$sData1 = StringMid($sHTML,StringInStr($sHTML,'/','',3)+1,StringInStr($sHTML,'/','',4)-StringInStr($sHTML,'/','',3)-1)
$sData2 = StringMid($sHTML,StringInStr($sHTML,'>','')+1,StringInStr($sHTML,'<','',2)-StringInStr($sHTML,'>','')-1)
Msgbox(0,'$sData1',$sData1&@CRLF&$sData2)
Link to comment
Share on other sites

This should pull them out

$sHTML = '<a href="/pyt/23204/XXJJE/jak-sciagnac-fotoszopa">Jak sciagnac fotoszopa??</a>'
$sData1 = StringMid($sHTML,StringInStr($sHTML,'/','',3)+1,StringInStr($sHTML,'/','',4)-StringInStr($sHTML,'/','',3)-1)
$sData2 = StringMid($sHTML,StringInStr($sHTML,'>','')+1,StringInStr($sHTML,'<','',2)-StringInStr($sHTML,'>','')-1)
Msgbox(0,'$sData1',$sData1&@CRLF&$sData2)

Realy i don't get it. But its working on my text files thanks.

One situation, how get source on red from this code in html?

<td class="questionTitle"><a href="/Category/028,011/2,212642221,Podobaja_Ci_sie_moje_klubowe_odznaki_.html" class="aquestion" >

Podobają Ci się moje klubowe odznaki ?2

</a>

</td>

Code html from: http://zapytaj.onet.pl/

Im making base were red things help me to 1: Make category, 2: Fill my category with questions

Edited by koszmail2
Link to comment
Share on other sites

I commented and expanded the code so that it may be easier to follow and you can learn to adjust it for your needs.

$sHTML = '<a href="/pyt/23204/XXJJE/jak-sciagnac-fotoszopa">Jak sciagnac fotoszopa??</a>'

$iSeperator_A = StringInStr($sHTML,'/','',3) + 1 ; returns location of 3rd '/', +1 to start at the character after '/'
$iSeperator_B = StringInStr($sHTML,'/','',4) - 1 ; returns location of 4th '/', , - 1 to end Before the 4th '/'
$iStrLength_1 = $iSeperator_B - $iSeperator_A ; returns length of the string to pull

$sData1 = StringMid($sHTML,$iSeperator_A,$iStrLength_1) ; returns a portion of the string, starting at $iSeperator_A and lasting for $iStrLength_1 characters

$iSeperator_C = StringInStr($sHTML,'>') + 1 ; returns location of 1st '>', +1 to start at the character after '>'
$iSeperator_D = StringInStr($sHTML,'<','',2) - 1 ; returns location of 2nd '<',  - 1 to end before the 2nd '<'
$iStrLength_2 = $iSeperator_D - $iSeperator_C ; returns length of the string to pull,

$sData2 = StringMid($sHTML,$iSeperator_C, $iStrLength_2) ; returns a portion of the string, starting at $iSeperator_C and lasting for $iStrLength_2 characters
Msgbox(0,'$sData1',$sData1&@CRLF&$sData2)
Edited by Shane0000
Link to comment
Share on other sites

using xml dom is cleaner, to parse out data:

$oXML=ObjCreate("Microsoft.XMLDOM")
$oXML.LoadXML('<td class="questionTitle"><a href="/Category/028,011/2,212642221,Podobaja_Ci_sie_moje_klubowe_odznaki_.html" class="aquestion" >Podobaja Ci sie moje klubowe odznaki ?</a></td>') ; load text of the DOM object
$result1 = $oXML.selectSingleNode('//a')
$result2 = $oXML.selectSingleNode([email="'//a/@href'"]'//a/@href'[/email])
ConsoleWrite ( $result1.text & @CRLF)
ConsoleWrite ( $result2.text & @CRLF)

edit: damn auto corrector, just because there is an @ sign does NOT an email make...replacing the @ with A, so i can write it in: $result2 = $oXML.selectSingleNode('//a/Ahref')

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

how about:

$result2 = "/Category/028,011/2,212642221,Podobaja_Ci_sie_moje_klubowe_odznaki_.html"
$result2 = StringRegExp ( $result2, "/([d,/]+),w", 3 )
$result2 = $result2[0]
MsgBox ( 1,1,$result2)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Moderators

Shane0000 & jdelaney,

Full marks for being helpful, but zero marks for being observant! :D

As the OP has been blocked since post #10, there seems little point in leaving this open as he does not deserve to be helped. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...