I have some code with data embedded in it. Here's a sample:
<div class='clear' ></div>
</div> <!-- findResultListing -->
<div class='findResultListing ' id='result_listing_7_0' onclick='examMapManagerHandle.clickMarker(7,0);'>
<a href='javascript:examMapManagerHandle.clickMarker(7,0);'>
<img class='balloon' src='/system/themes/asp/img/gmarkerH.png' border='0' />
</a>
<div class='findResultInfo'>
<div class="nextStep">
<a href="/system/modules/shibboleth/secure_find/shib_gateway.php?url=%2Fexams%2Fschedule.php%3Fnav%3Dexams%2Cstucourses%2Cexams%2Csched_exam%26amp%3Badd_locid%3D1672">
<img height="16" border="0" align="left" width="16" src="/system/themes/asp/img/schedule.png"/>Schedule Exam
</a>
</div>
<a href='javascript:examMapManagerHandle.clickMarker(7,0);' >
SJSU Testing
<img class='userType' border='0' src="/system/themes/asp/img/org.png" alt='Testing Site' title='Testing Site'/>
</a>
<br />
One Washington Square<br />
Industrial Studies Building 228<br />
San Jose, CA 95112<br />
Phone: (408) 924-5980<br />
Email: <span id="_smarty_mailto_span_2096382943_1423929156_8"> </span>
<noscript>To see email address, enable javascript</noscript>
<script type="text/javascript">var mailto=document.getElementById("_smarty_mailto_span_2096382943_1423929156_8");
mailto.innerHTML='<a href="mailto:testing-office#sjsu.edu" >testing-office#sjsu.edu</a>';</script><br />
Fee for two hour exam:
$40.00
<a class="helpBtn" onmouseover="asp_toolTip(this,' <strong>Fee Details:<\/strong> We charge $20 for the first hour and $10 for each half hour after... <br /> <strong>Miscellaneous Fees:<\/strong> Test emailed in pdf/Word Doc., we will charge an administrative fee of $15 for 10 or more test pages <br /> <strong>Parking Fee Details:<\/strong> Its $8.00 to park in the 10th St. garage on the corner of 9th & E. San Fernando Sts.', 'findResultsToolTip', 'fit_west', 'map_results_pane');"></a>
<br />
</div><!-- findResultInfo -->
I want to extract just the following from the above code:
SJSU Testing Testing Site
One Washington Square
Industrial Studies Building 228
San Jose, CA 95112
Phone: (408) 924-5980
Email: testing-office#sjsu.edu
Fee for two hour exam: $40.00
What are some ways in which I can automate the extraction of this data from the code?
Using Xpath I would make usage of this expression:
//*/text()
Related
I am running the latest version of contact form 7 on my site and all of the forms are working flawlessly except one. I keep getting the message "Failed to send your message.
Please try later or contact the administrator by another method." I haven't come across any errors in the console and have tried everything from deleting the entire plugin and re-entering all the forms to deleting and recreating the problem form. I have tried all the troubleshooting suggestions I could find.
I am at a complete loss if anyone has any suggestions it would be incredibly helpful.
The form is located at: http://test.drummerrealty.com/management-services/#inquiries.
Here is the code:
Form:
Contact Information
<div class="row">
<div class="col-md-3 col-sm-12">
<p>First Name *<br />
[text* first-name] </p>
<p>Last Name *<br />
[text* last-name] </p>
</div>
<div class="col-md-3 col-sm-12">
<p>Your Email *<br />
[email* your-email] </p>
<p>Telephone *<br />
[tel* tel-819]</p>
</div>
<div class="col-md-3 col-sm-12">
<p>Property Address<br />
[text address]</p>
<p>City<br />
[text city]</p>
</div>
<div class="col-md-3 col-sm-12">
<p>Province<br />
[text province]</p>
<p>Postal Code<br />
[text postal-code]</p>
</div>
<h3>Property Information</h3>
<div class="row">
<div class="col-md-6 col-sm-12">
<p>Property Class:<br />
[select property use_label_element "Condominium" "Townhome" "Single Family Dwelling" "Apartment Block"]</p>
<p>Year Built<br />
[number build-year min:1900 max:3500]</p>
<p>Number of Bedrooms:<br />
[select num-bed "1" "2" "3" "4" "5+"]</p>
<p>Number of Bathrooms:<br />
[select num-bath "1" "1.5" "2" "2.5" "3" "3.5" "4" "4.5" "5+"]</p>
<p>When do you plan to lease this property? (yyyy-mm-dd)<br />
[date date-lease] </p>
</div>
<div class="col-md-6 col-sm-12">
<p>Style & Features<br />
[checkbox features use_label_element "Bungalow" "2-storey" "Apartment" "Walk-out Basement" "Gated Community" "Parking " "Attached Garage" "Detached Garage"]</p>
<p>Square Footage<br />
[number sq-foot]</p>
</div>
<div class="row">
<div class="col-sm-12">
<p>Additional Details<br />
[textarea add-details] </p>
<p>[submit "Send"]</p>
</div>
Mail:
From: [first-name] [last-name]
Subject: Property Management form from [first-name] [last-name]
Message body:
Contact Information
First Name: [first-name]
Last Name: [last-name]
Your Email: [your-email]
Telephone: [tel-819]
Property Address: [address]
City: [city]
Province: [province]
Postal Code: [postal-code]
Property Information
Property Class: [property]
Style & Features: [features]
Square Footage: [sq-foot]
Year Built: [build-year]
Number of Bedrooms: [num-bed]
Number of Bathrooms: [num-bath]
When do you plan to lease this property?: [date-lease]
Additional Details: [add-details]
I am trying to use R to log into this website: http://www.broadinstitute.org/cmap/signature?servletAction=edit with the following code
library("RCurl")
connectivityMap_detailed_results <- function(up_grp, down_grp){
params <- list('j_username' = 'username',
'j_password' = 'password')
cmap <- postForm("http://www.broadinstitute.org/cmap/signature?servletAction=edit",
.params=params, style="POST")
print(cmap)
However, print(cmap) still shows the log-in page.
I also tried
tmp <- getURL("http://www.broadinstitute.org/cmap/signature?servletAction=edit",
userpwd = "user:pwd",verbose=TRUE)
with the same result.
How can I use RCurl to log in on that website?
cmap result
[1] "
<html>
<head>
<link href="styles/stylesheet.css" rel="stylesheet" type="text/css">
<link rel="SHORTCUT ICON" href="favicon.ico" >
<title>Connectivity Map sign-in</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<div style="overflow: hidden;"><img border="0" src="images/banner1.jpg" alt="cmap" title="cmap"></div>
<div align="right" style="text-align: right;" width="100%">
</div>
<div id="tabContainer" class="tabContainer"><span id="tabSpace" class="tabSpace"> </span></div>
<div class="error"></div>
<br><br>
<form name="login2" target="_top" method="POST" action="j_security_check">
<table>
<tr>
<td align="right" valign="top">
username:
</td>
<td valign="top">
<input name="j_username" size="50" value="">
</td>
</tr>
<tr>
<td align="right" valign="top">
password:
</td>
<td valign="top">
<input type="password" name="j_password" size="50">
</td>
</tr>
<tr>
<td align="right" valign="top">
</td>
<td valign="top">
<input type="submit" name="submit" value="sign in" class="little">
<br/><br/>
email me my password |
register as a new user
</td>
</tr>
</table>
</form>
<hr/>
<p class="intro">The Connectivity Map (also known as cmap) is a collection of genome-wide transcriptional expression data from cultured human cells treated with bioactive small molecules and simple pattern-matching algorithms that together enable the discovery of functional connections between drugs, genes and diseases through the transitory feature of common gene-expression changes. You can learn more about cmap from our papers in <a target="_blank" href="http://www.sciencemag.org/cgi/content/full/313/5795/1929?ijkey=ylc.v/5sDLGKI&keytype=ref&siteid=sci"><i>Science</i></a> and <a target="_blank" href="http://www.nature.com/nrc/journal/v7/n1/pdf/nrc2044.pdf"><i>Nature Reviews Cancer</i></a>.
<!--table>
<tr><td align="right"><img src="images/scienceMag.png" height="25" style="padding-left: 25px;"></td><td> read our paper in Science Magazine<br/> </td></tr>
<tr><td align="right"><img src="http://www.broad.mit.edu/images/homelogo.gif" height="25" style="padding-left: 25px;"></td><td> an article about cmap at The Broad Institute website<br/> </td></tr>
<tr><td align="right"><img src="images/audio.gif" style="padding-left: 25px;"></td><td> listen to an interview on National Public Radio with Todd Golub about cmap<br/> </td></tr>
</table-->
</p>
<p class="intro">This web interface provides access to the current version (<b>build 02</b>) of Connectivity Map which contains more than 7,000 expression profiles representing 1,309 compounds. It is designed to allow biologists, pharmacologists, chemists and clinical scientists to use cmap without the need for any specialist ability in the analysis of gene-expression data. The previous version (<b>build 01</b>) of Connectivity Map can be accessed here.</p>
<p class="intro">A brief tutorial can be found by clicking 'getting started' under the 'help' tab after log in. Detailed help and a definition of cmap terms can be found by clicking 'topics', also under the 'help' tab. For everything else, please contact us.</p>
<p class="intro">The Connectivity Map is based at The Broad Institute of MIT and Harvard in Cambridge, Massachusetts. The cmap team is Justin Lamb, Xiaodong Lu, Dave Peck, Matt Wrobel, Aravind Subramanian, Irene Blat, Josh Modell, Jim Lerner, Elizabeth Liu and Emily Crawford. Jean-Philippe Brunet, Ken Ross, Michael Reich, Paul Clemons, Kathy Seiler, Steve Haggarty, Bang Wong, Maria Nemchuk, Ru Wei, Steve Carr, Christopher Johnson, Stephen Johnson, the MSigDB curation team, and the Genetic Analysis Platform contribute invaluable expertise and assistance. Todd Golub and Eric Lander provide institutional leadership for the project.</p>
<hr/>
privacy statement | terms and conditions<br/>
<img src="images/homelogo.gif" border="0"/>
<br/>© 2006 Broad Institute
<!--p class="intro">The Broad Institute is a research collaboration of MIT, Harvard and its affiliated Hospitals, and the Whitehead Institute, created to bring the power of genomics to medicine.</p-->
<script language="javascript">
document.login2.j_username.focus()
</script>
</body>
</html>
"
attr(,"Content-Type")
charset
"text/html" "ISO-8859-1"
You're using the wrong url. To submit the form you have to post to the url specified in the action=... attribute of the <form> element.
library(RCurl)
url <- "http://www.broadinstitute.org/cmap/j_security_check"
params <- list('j_username' = 'username',
'j_password' = 'password')
cmap <- postForm(url, .params=params, style="POST")
library(XML)
doc <- htmlTreeParse(cmap, useInternalNodes=T)
xmlValue(doc["//head/title"][[1]]) # page title
# [1] "login failure"
The login fails of course because I don't know the username and password.
I am using a RadRotator as following for getting an RSS feed from google:
<telerik:RadRotator ID="RadRotator1" RotatorType="AutomaticAdvance" ScrollDirection="Up"
ScrollDuration="2000" runat="server" DataSourceID="XmlDataSource1" Width="493"
ItemWidth="493" Height="192" ItemHeight="75" FrameDuration="1" InitialItemIndex="-1"
CssClass="rotator">
<%# XPath("item") %>
</ItemTemplate>
What is happening is that nothing is showing in the radgrid when I do
<%# XPath("item") %>
Note that I need item as this is has the title, desciption etc. a you can see in the sniplet below
but if I do
<%# XPath("description") %>
I see the description but the item is what I need..
Here is what a sniplet of the google rss xml file looks like:
<rss version="2.0"><channel><generator>NFE/1.0</generator><title>malaria - Google News</title><link>http://news.google.com/news?pz=1&ned=us&hl=en&q=malaria</link><language>en</language><webMaster>news-feedback#google.com</webMaster><copyright>©2012 Google</copyright><pubDate>Thu, 25 Oct 2012 14:56:08 GMT</pubDate><lastBuildDate>Thu, 25 Oct 2012 14:56:08 GMT</lastBuildDate><image><title>malaria - Google News</title><url>https://ssl.gstatic.com/news/img/logo/en_us/news.gif</url><link>http://news.google.com/news?pz=1&ned=us&hl=en&q=malaria</link></image><item><title>Malaria and Acquired Immunity - AllAfrica.com</title><link>http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNHNkVuoonL7HkcwkSoAldZPsWUvNg&url=http://allafrica.com/stories/201210251151.html</link><guid isPermaLink="false">tag:news.google.com,2005:cluster=http://allafrica.com/stories/201210251151.html</guid><pubDate>Thu, 25 Oct 2012 12:16:20 GMT</pubDate><description><table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"></font></td><td valign="top" class="j"><font style="font-size:85%;font-family:arial,sans-serif"><br /><div style="padding-top:0.8em;"><img alt="" height="1" width="1" /></div><div class="lh"><b><b>Malaria</b> and Acquired Immunity</b><br /><font size="-1"><b><font color="#6f6f6f">AllAfrica.com</font></b></font><br /><font size="-1">Even though the economic impact in Zambia has not yet been quantified, it is likely to be substantial due to the number of productive days lost due to the number of productive days lost due to <b>malaria</b>. The intensity of <b>malaria</b> in an area determines the <b>...</b></font><br /><font size="-1" class="p"></font><br /><font class="p" size="-1"><a class="p" href="http://news.google.com/news/more?ncl=dPdXW_JAl88mIRM&ned=us"><nobr><b>and more »</b></nobr></a></font></div></font></td></tr></table></description></item>
Note that I am just trying to get the item portion of it as the item is the wrapper for description,etc.
here is the code snippet for your scenario:
XML Data Source Definition:
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&q=malaria&output=rss"
XPath="rss/channel/item"></asp:XmlDataSource>
RadRotator definition:
<telerik:RadRotator ID="RadRotator1" RotatorType="AutomaticAdvance" ScrollDirection="Up"
ScrollDuration="1000" runat="server" DataSourceID="XmlDataSource1" Width="493"
ItemWidth="493" Height="250" ItemHeight="250" FrameDuration="2000" InitialItemIndex="-1"
CssClass="rotator">
<ItemTemplate>
<div style="border: 1px solid darkgray; padding : 10px;background-color:lightgrey">
<a href='<%# XPath("link") %>'><%# XPath("title") %></a>
<div>
<%# XPath("description") %>
</div>
</div>
</ItemTemplate>
</telerik:RadRotator>
The way to reach an item in RSS feed is through the path rss/channel/item - this will give all the items in the document. Then in the item template i am just grabbing the link, title and description. Item is a parent node and thats why
Here is the output of the above code:
I'm trying to get the Ajax Toolkit rating control working in ASP.NET 4. I've added it to the page, and added the registration statement but it renders as invisible (ie: it renders on the page with display:none.
I have a standard scriptmanager on my masterpage, and a standard scriptmanagerproxy on the page itself.
I've tried putting the rating in an updatepanel, but the same thing happens.
This is my code:
<ajaxToolkit:Rating ID="ratRating" runat="server" MaxRating="5" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" OnChanged="rating_Changed" />
Which results in the following code (notice it's hidden with an inline style)
<div id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating">
<input type="hidden" value="3" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_RatingExtender_ClientState" name="ctl00$ctl00$ctl00$cphBody$cphBody$cphBody$editRecipeForm$ratRating_RatingExtender_ClientState">
<a style="text-decoration:none" title="3" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_A" href="javascript:void(0)">
<span style="float:left;" class="ratingStar filledRatingStar" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_Star_1"> </span>
<span style="float:left;" class="ratingStar filledRatingStar" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_Star_2"> </span>
<span style="float:left;" class="ratingStar filledRatingStar" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_Star_3"> </span>
<span style="float:left;" class="ratingStar emptyRatingStar" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_Star_4"> </span>
<span style="float:left;" class="ratingStar emptyRatingStar" id="ctl00_ctl00_ctl00_cphBody_cphBody_cphBody_editRecipeForm_ratRating_Star_5"> </span>
</a>
</div>
I find it odd that there's no error message displayed, and I haven't explicitly hidden the control anywhere.
It's probably not invisible, but rather the images locations of the rating star classes are wrong.
Check your css classes ratingStar, filledRatingStar, and emptyRatingStar.
I never saw that problem and I have no idea what is causing it.
I got something like this code in my masterpage
<div class="myClass1">
<a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">
<asp:Literal runat="server" Text="<%$ Resources: myRess1 %>" /><br />
<img class="myClass2" src="/MasterPage/images/myGif.gif" width="19" height="12" alt="" />
</a>
</div>
when I browse a page that using this master page, the code become
<div class="myClass1">
<a href="#link#link" title="myTitle">
myTitle<br />
<img class="myClass2" src="/MasterPage/images/.gif" width="19" height="12" alt="" /><br />
</a>
</div>
why does the link double itself?
if I put something like default.aspx instead of #link, it work perfectly.
The reason why I'm using "~/" is because the master page is located somewhere else, if I don't put ~/ it make the link as /masterpage/#link which is invalid
The ~/ should not be necessary. Just use #link
'~' can be used only with server controls and not with html controls. You should just use href="#link".
for now I changed my
<a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">
to
<a href="#link" title="<%=GetLocalResourceObject("myRess1 ") %>">
and it's working fine but if someone could tell me why with runat="server" screw up the #link, that would be good to know