Hi everyone,
I am building a web crawler and one of the features which I need to
include is exclusion of specified 'variable + value' from the url.
Example, user wanted to extract variable "s":
So when you look at this url:
"http://www.goldenretri everforum.com/search.php?s=58 17617a59fb630a7 f40846e4a29efc1 &do=getdaily "
, it has a variable 's' and its value, plus some other variables.
I need a code which would shorten that url to this:
"http://www.goldenretri everforum.com/search.php?do=g etdaily"
, extracting variable 's' completely.
But it needs to be smart to such point, that is variable 's' is the
last variable in the link, like this:
"http://www.goldenretri everforum.com/search.php?s=58 17617a59fb630a7 f40846e4a29efc1 "
, it would correctly fix it to:
"http://www.goldenretri everforum.com/search.php"
Can someone help me write REGEX or point me to site which has such
regex written already?
Or is there any other way to do this?
Thanks a lot for your time and help.
Joe 4 3178
try regex
I am not good at this but I try give you a hint and example I saw
sample pattern that splits url into 5 match groups:scheme,
authority, path, query, fragment
"({[^:/?#]+}:)?(//{[^/?#]*})?{[^?#]*}(?{[^#]*})?(#{.*})?"
"({[^:/?#]+}:) // scheme
?(//{[^/?#]*}) //authority
?{[^?#]*} // path
(?{[^#]*})? // query
(#{.*})?" // qusty
you use match.groups for the above
For detail instructions, search for regex on msdn
pattern could be something like your s variable and value could be
"s=[a-z0-9]*\&"
You could even use regex to remove to the pattern "s=[a-z0-9]*\&" from the
url.
"Jozef Jarosciak" <jo*@doprocess. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Hi everyone,
I am building a web crawler and one of the features which I need to include is exclusion of specified 'variable + value' from the url.
Example, user wanted to extract variable "s":
So when you look at this url: "http://www.goldenretri everforum.com/search.php?s=58 17617a59fb630a7 f40846e4a29efc1 &do=getdaily "
, it has a variable 's' and its value, plus some other variables.
I need a code which would shorten that url to this: "http://www.goldenretri everforum.com/search.php?do=g etdaily" , extracting variable 's' completely. But it needs to be smart to such point, that is variable 's' is the last variable in the link, like this:
"http://www.goldenretri everforum.com/search.php?s=58 17617a59fb630a7 f40846e4a29efc1 "
, it would correctly fix it to: "http://www.goldenretri everforum.com/search.php"
Can someone help me write REGEX or point me to site which has such regex written already?
Or is there any other way to do this?
Thanks a lot for your time and help.
Joe
Hi, thanks, when it comes to regex I am completely off.
Is there anyone who could write this (supposedly) simple regex for
extraction of variable 's' from the url?
joe
given:
http:// nowhere.com /folder/file.txt?v1=hel lo%20world
expression could be:
(?<variable> (?<name> .*?) = (?<value> .*?) \& | $ )
Use a "Uri" object to grab the querystring only and to reset it later if required
The above expression should parse all name=value pairs from a querystring.
(Must use RegexOptions.Ig norePatternWhit eSpace and RegexOptions.Si ngleline)
You can use the Group["name"].Value, etc to obtain the strings to compare
You can use group indexes to manipulate the querystring
--
Dave Sexton dave@www..jwaon line..com
-----------------------------------------------------------------------
"Jozef Jarosciak" <jo*@doprocess. com> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Hi, thanks, when it comes to regex I am completely off. Is there anyone who could write this (supposedly) simple regex for extraction of variable 's' from the url? joe
Hello,
I wrote this tutorial a while ago on parsing using the URI class: http://www.geekpedia.com/tutorial68_...URI-Class.html
Hopefully it will get you on the right path, at least.
Andrei
"Dave" <NO*********@do tcomdatasolutio ns.com> wrote in message
news:Om******** ******@tk2msftn gp13.phx.gbl... given:
http:// nowhere.com /folder/file.txt?v1=hel lo%20world
expression could be:
(?<variable> (?<name> .*?) = (?<value> .*?) \& | $ )
Use a "Uri" object to grab the querystring only and to reset it later if required
The above expression should parse all name=value pairs from a querystring. (Must use RegexOptions.Ig norePatternWhit eSpace and RegexOptions.Si ngleline)
You can use the Group["name"].Value, etc to obtain the strings to compare You can use group indexes to manipulate the querystring
-- Dave Sexton dave@www..jwaon line..com ----------------------------------------------------------------------- "Jozef Jarosciak" <jo*@doprocess. com> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Hi, thanks, when it comes to regex I am completely off. Is there anyone who could write this (supposedly) simple regex for extraction of variable 's' from the url? joe
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jerry Sievers |
last post by:
<venting>
Fellow coders;
I just get off the phone today with some clueless headhunter and after
listing for her (very proudly I might add) my OS and dev tools
platforms of choice;
Linux/Apache/Postgres/PHP
I get a few moments of silence and she mentiones to me some new wizzy
|
by: Matthew Barnes |
last post by:
I'm considering submitting a patch for Python 2.4 to allow environment
variable expansion in ConfigParser files. The use cases for this
should be obvious. I'd like to be able to specify something like the
following in a configuration file:
data_file=${HOME}/mydata.dat
....(where HOME=/home/matt) and have ConfigParser automatically expand
it to:
|
by: BA |
last post by:
Hello,
I have a string with a price in: "$14.95"
I need to get it into a decimal.
So I regex 'd the string and dumped the $. Debug mon shows a clean string
"14.95"
Then I do a System.Convert.ToDecimal on the clean string and the output
|
by: .:mmac:. |
last post by:
I have a bunch of files (Playlist files for media player) and I am trying to
create an automatically generated web page that includes the last 20 or 30
of these files. The files are created every week and are named XX-XX-XX.ASX
where the X's represent the date i.e. 05-22-05.asx
The files are a specific format and will always contain tags like the
following:
<TITLE>My media file title</TITLE>
<AUTHOR>Media file author</AUTHOR>
<Ref href =...
|
by: Hai Nguyen |
last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalent
object used in c sharp.
Translate these two lines to C sharp:
Sub Next_Click(Sender As Object, e As EventArgs)
Select Case...
| |
by: Klaus Alexander Seistrup |
last post by:
Hi group,
I am new to xgawk (and seemingly to xml also), and I've been struggling
all afternoon to have xgawk¹ parsing an XHTML file containing a hCard²,
without luck. I wonder if you guys could give me a push...
Let's say I have the following XHTML file:
#v+
|
by: windandwaves |
last post by:
Hi Folk
I am a PHP programmer, but I like to learn c-sharp as it seems to be
in hot demand around here. My questions are:
- how does c-sharp relate to PHP
- do you like c-sharp and its cousins
- are there better things to do then c-sharp?
Thanks a million
|
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple command set consisting of several single letter
commands which take no arguments. A few additional single letter
commands take arguments:
|
by: complete |
last post by:
What is the point of using set and get in C Sharp?
It seems variables are used differently in this language than in C++.
For some reason, you have to have a static variable defined like this:
public static uint Somenum
{
set { m_somenum = value; }
get { return m_somenum; }
}
and prior to this declaration, you need to have this:
public uint m_sumenum;
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |