I am trying to use VBS to gather names of files from a website. I can get the HTML code but I don't know how to extract the name. I haven't yet found anything that can do what I need. I need to extract the name of a file from a table. The HTML around what I need looks like this tsc_details.php?show_id=NEEDED INFO"> There are many different names formatted this same way and the number of names will vary from time to time.
NOTE: There will be multiple of these at various places in the HTML code.
Here is my code
On Error Resume Next
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "WWW.Webpage.com"
ie.Visible = True
While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
ie.document.getElementById("f_user").Value = "user"
ie.document.getElementById("f_pass").Value = "pass"
ie.document.All.Item("submitb").Click
While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
This is all of the code I have. It works perfectly for logging in to the page I just don't know how to get the Information I need.
Figured it out and wanted to share my findings in case it helped someone out.
For Each a In IE.Document.GetElementsByTagName("A")
If InStr(a.GetAttribute("href"),"tsc_details.php?show_id=") > 0 Then
var = a.GetAttribute("href")
var = Replace(var,"tsc_details.php?show_id=","")
exit for
end if
next
Used this code
Related
Good day all! I am working on a parser for a chat room that can color text based on who was talking for archive purposes. I have it working perfectly, except now the administrator wants to be able to remove the "fancy" names and replace with more readable versions for some of their regular people.
The chat room allows an extended range of letters and symbols to use, that, when transferred to a rtf file, may not exactly transfer fully.
I cant get it to work, and dont see any reason why it should not.
This is an example of what I have:
$nameconvert = array(
"îrúål__Þħōþħ" => "Eriel__Thoth",
);
***Scripting that parses an uploaded text
file line by line, each line places in an
array using space as delimiter... thus
name of person talking is $row_data[0]***
$name = $row_data[0];
$name = $nameconvert[$name];
** Code to throw everything back together **
Now, this is just a simplified snippet, but for whatever reason, it does not work. Now if I did $name = $nameconvert['îrúål__Þħōþħ'] then it does work, telling me that the name im putting in script, and name being pulled from mytext file are two different things, though they are visually identical
HELP!
I have found the answer, and wish to share my solution to others.
This is the modified code
$nameconvert = array(
"0123456789abcdef" => "Eriel__Thoth",
);
***Scripting that parses an uploaded text
file line by line, each line places in an
array using space as delimiter... thus
name of person talking is $row_data[0]***
$name = $row_data[0]
$name = $nameconvert[bin2hex(mb_convert_encoding($name,"UTF-8"))];
$name = $nameconvert[$name];
** Code to throw everything back together **
The command bin2hex(mb_convert_encoding($name,"UTF-8")) takes the name from the file, ensures it is in UTF-8 format, then creates its hexadecimal equivalent. It then uses that in the array to correspond to a easier to read name
It works just the way I am wanting!
Basically, I have an administration area where users are to be able to add information to a MySQL database using a form textarea. The users have little or no HTML knowledge so I'd like them to be able to use their return key to create line breaks instead of <br /> tags, however I also want the use of HTML to be permitted too for future purposes. I also won't want <br /> tags to appear in the textarea after insertion and would like line breaks instead so as not to confuse people - basically display it in the textarea exactly as it was entered.
I've been having difficulty parsing the data though, I've come up with a solution to prevent the line breaks from being stripped but I just really want to know if this is valid - it works, but if I've learned anything recently I know that doesn't mean it's right!
$extra_details_escape = mysql_real_escape_string($_POST['extra_details']);
$extra_details_escape = str_replace('\r\n','LiNeBrEaK',$extra_details_escape);
$extra_details_escape = stripslashes($extra_details_escape);
$extra_details_escape = str_replace('LiNeBrEaK','\r\n',$extra_details_escape);
mysql_query("UPDATE table SET column = '$extra_details_escape' WHERE id = '$id'");
Many thanks,
Joe
Have you tried nl2br() ?
Try this, post string sanitization:
$extra_details_escape = nl2br($_POST['extra_details']);
I have a weird question. I want to create script in javascript (or PHP if I have to, I'm just more comfortable in javascript) that reads through a table until it finds specific text (know how to do that) and then returns the text three cells to the right.
To be specific, I want a script that finds a row for a specific printer on this site and returns the printer's status. I know how to select unique text, but not so much about nonunique text.
Try this
$('.epi-dataTable tr:gt(0) td:first-child:contains("printerName")')
.closest('tr').find('td:eq(4)').text();
var printerName = 'yourname',
status = $(':contains(' + printerName + ')').siblings().eq(2).text();
If I understood your question correctly, this is how you could do it using jQuery:
$("td").filter(function() {
return $(this).text() === yourSeachText;
}).next().next().next().text();
Clarifying: the filter function will select only the column whose text equals your search text, and each call to next will return the column's next sibling - another td. Three calls later, you have the column you want, so you can get its text.
Update: you might also be interested in this question, if the site you're querying is not in the same domain as your script. If it is, you can simply load its contents to a div before querying it:
$("#placeholder").load("http://clusters.andrew.cmu.edu/printerstats/", function() {
// The contents were loaded to #placeholder, do your query here
});
If it's not, then you'll have to load that html data somehow, and according to an anwser to that question, your best route is really to do it in PHP (or at least use it to echo the other site's contents to your own).
I have a file for a calendar made with javascript called calendar_db.js, in it there is this if statment:
if (d_current.getDay() != 3 && d_current.getDay() != 6)
a_class[a_class.length] = 'available';
it checks if the day is not the 3d or the 6th then. So my question is how to make a php mysql query to get those numbers (3 and 6) because I want to change them with mysql databse.
What are your suggestions?
Thank you for your time and help.
The short answer is:
You can't
However, you can use Ajax (Google it) to make calls to an external php file, which will process your request for you. Then, the php file can print out the result, which will send the information back to you.
Take a look here:
http://www.w3schools.com/ajax/default.asp
EDIT:
Read the javascript file by using fopen(), file_get_contents(), or CURL:
http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx
Use some kind of regex to parse the javascript file looking for the particular match of the line with your values. If your javascript file isn't going to change much, it might be easier to just count lines and characters and get the number at exactly some position. This assumes your numbers will always be single digits.
Is this what you're after?
You have to use AJAX to interact with the server via JavaScript.
Since the code to setup an AJAX request is a bit long and tedious, I'll show you how to do it with the jQuery framework.
Basically, just make the server spit the two values out (imagine this being the output of foo.php):
12,19
Now, with AJAX you can read that output. There are two types of requests: GET and POST. If you're familiar with PHP, you can change this according to what your application uses:
var day1, day2;
$.get('foo.php', function(data) {
var split = data.split(',');
day1 = parseInt(split[0]);
day2 = parseInt(split[1]);
});
Now day1 and day2 hold your two dates.
Out company operate numerous servers
We are using a internal script to filter out various pieces of information , The frontend users will be say entering a postcode , it will then process a list of 5 pages in 1 page of information .
Note: we know our code may not be the most simplistic but it seems to work at the moment , any 1 that knows a easier way to do it then please do say
<?php $postcode = $_POST['postcode']; ?>
// get DOM from URL or file
$html = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=$postcode&x=39&y=9&Page=1');
$html1 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=$postcode&x=39&y=9&Page=2');
$html2 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=sa11&x=39&y=9&Page=3');
we have further code which filters out our servers results , but for some reason when one of our users posts the form to this script , only the bottom result is coming back purely because the location is hardcoded - the others are coming back unknown and we think that it isnt passing the postcode variable to the urls correctly
could it be because the $postcode variable is already inside the $html variable , is there a way to get around this issue ?
Thanks
the string beetwen single quotes (') don't get evaluated. try something like
$html = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location='.$postcode.'&x=39&y=9&Page=1');
$html1 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location='.$postcode.'&x=39&y=9&Page=2');
and check the $postcode value for valid values before using it in your programs, please