473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

vb6 parsing and adding to .txt

ok i have vb6 and i need to parse something from a web site source and have it add the parsed to a txt file.

example:

Expand|Select|Wrap|Line Numbers
  1. <tr><td>1,400</td><td><a target="_self" href="pro.php?pro=16003&amp;PHPSESSID=60b57bea646051deae63662d88bfa4d1"><font color
i need everything on one page parsed between

Expand|Select|Wrap|Line Numbers
  1. href="pro.php?pro=
and
Expand|Select|Wrap|Line Numbers
  1. &amp;PHPSESSID=
in this case 16003

then i need to add it to a txt file as this.

Expand|Select|Wrap|Line Numbers
  1. URL GOTO=http://webpage.com/16003
that will be in the txt file with all the different numbers at the end of each link.

now how do I go about doing this? i used to know how but i cant find anything on/about it please help thank you[/quote]
Jun 8 '07 #1
4 2921
jeffbroodwar
118 100+
can you try to elaborate the problem? it's actually confusing.... i hope i can help...
Jun 8 '07 #2
can you try to elaborate the problem? it's actually confusing.... i hope i can help...
Hi
if you wanna work multilanguage (VB6+PHP) I think the easiest way is:

- saving the page into htm or html
OR
- use IE activex

(by you know we can't export php commands from a web server) so then open the file into a string variable then attach your PHP commands to it.

also see http://www.thescripts.com/forum/thread659246.html
Jun 8 '07 #3
danp129
323 Expert 256MB
ok i have vb6 and i need to parse something from a web site source and have it add the parsed to a txt file.
How to get webpage source

i need everything on one page parsed between
Expand|Select|Wrap|Line Numbers
  1. href="pro.php?pro=
and
Expand|Select|Wrap|Line Numbers
  1. &amp;PHPSESSID=
How to parse page:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Dim sString 'As String
  3.     Dim sPattern 'As String
  4.     Dim ret
  5.     Dim i 'As Long
  6.     Dim sURLPrefix 'As String
  7.     Dim sLineOutput 'As String
  8.     sURLPrefix = "URL GOTO=http://webpage.com/"
  9.  
  10.     sString = "<tr><td>1,400</td><td><a target=""_self"" href=""pro.php?pro=16003&amp;PHPSESSID=60b57bea646051deae63662d88bfa4d1""><font color<tr><td>1,400</td><td><a target=""_self"" href=""pro.php?PHPSESSID=60b57bea646051deae63662d88bfa4d1&pro=17432""><font color<tr><td>1,400</td><td><a target=""_self"" href=""pro.php?pro=987621&PHPSESSID=60b57bea646051deae63662d88bfa4d1""><font color"
  11.     sPattern = "href=['\""]pro\.php[^'\""]*?pro=([0-9]+)"
  12.  
  13.  
  14.     ret = GetPro(sPattern, sString)
  15.  
  16.     If UBound(ret) < 0 Then
  17.         MsgBox "No match found"
  18.         Exit Sub
  19.     End If
  20.  
  21.     For i = 0 To UBound(ret)
  22.         sLineOutput = sURLPrefix & ret(i)
  23.         'put your code here to output the string to text file
  24.         MsgBox sLineOutput
  25.     Next 'i
  26.  
  27.     If IsArray(ret) Then Erase ret
  28.  
  29. End Sub
  30.  
  31. Function GetPro(myPattern, myString)
  32.     'Create objects.
  33.     Dim objRegExp   ' As RegExp
  34.     Dim objMatch    ' As Match
  35.     Dim colMatches  ' As MatchCollection
  36.     Dim RetStr      ' As String
  37.     Dim sDelim, sDelim2
  38.     Dim objSubMatch
  39.  
  40.     ' Create a regular expression object.
  41.     Set objRegExp = CreateObject("VBScript.RegExp") ' New RegExp
  42.  
  43.     'Set the pattern by using the Pattern property.
  44.     objRegExp.Pattern = myPattern
  45.  
  46.     ' Set Case Insensitivity.
  47.     objRegExp.IgnoreCase = True
  48.  
  49.     'Set global applicability.
  50.     objRegExp.Global = True
  51.     'On Error resume next
  52.     'Test whether the String can be compared.
  53.     If (objRegExp.Test(myString) = True) Then
  54.         'Get the matches.
  55.         Set colMatches = objRegExp.Execute(myString)   ' Execute search.
  56.  
  57.         For Each objMatch In colMatches   ' Iterate Matches collection.
  58.           If objMatch.SubMatches.Count > 0 Then
  59.             RetStr = RetStr & sDelim
  60.             sDelim2 = ""
  61.             For Each objSubMatch In objMatch.SubMatches
  62.               RetStr = RetStr & sDelim2 & objSubMatch
  63.               sDelim2 = ","
  64.             Next 'objSubMatch
  65.             sDelim = vbCrLf
  66.           Else
  67.             RetStr = RetStr & sDelim & objMatch.Value
  68.             sDelim = vbCrLf
  69.           End If
  70.         Next
  71.     Else
  72.         'RetStr = "String Matching Failed"
  73.     End If
  74.    TestRegExp = Split(RetStr, vbCrLf)
  75. Exit Function
  76. errortrap:
  77. MsgBox "error"
  78.  
  79. End Function
  80.  
then i need to add it to a txt file as this.

Expand|Select|Wrap|Line Numbers
  1. URL GOTO=http://webpage.com/16003
that will be in the txt file with all the different numbers at the end of each link.
How to write to a file

Good luck
Jun 8 '07 #4
Thx alot im still kinda new to coding so some of it is weird to me but ill work through it and get it working thx alot i really like this site already lol
Jun 8 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: Fuzzyman | last post by:
I want to parse some text and generate an output that is similar but not identical to the input. The string I produce will be of similar length to the input string - but a bit longer. I'm...
6
by: Ian McConnell | last post by:
I've got a header file which lists a whole load of C functions of the form int func1(float *arr, int len, double arg1); int func2(float **arr, float *arr2, int len, double arg1, double arg2); ...
0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... I´ve written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
4
by: Pushya | last post by:
Hello - I am trying to parse a .XSD file to obtain information about element name and type in the file. I have been trying to find some kind of documentation for Schema Parsing. All I come...
9
by: Mantorok Redgormor | last post by:
If I am parsing a config file that uses '#' for comments and the config file itself is 1640 bytes, and the format is VARIABLE=VALUE, is it recommended to use a) fgetc (parse a character at a...
3
by: Badri | last post by:
I have a program that runs as a windows service waking up at predefined intervals to send out mails. Each mail is based on a template with tags to replace with database data from that specific row...
1
by: martinsson | last post by:
Hi all! I'm pretty mad about this... dont know what is going on. Im parsing XML file that looks like this: <something> __<item att="something">text<item> __<item...
0
by: bruce | last post by:
Hi Fredrick Thanks for the reply. But since I don't have control of the initial text, is there something with python that will strip/replace this... or are you saying I should do a...
6
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.