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.
Related
I am building a document catalogue in Dreamweaver CS6 using asp VB Script and Access as my DB. I have a "documents" table with attributes of
-refid (PK) .........(this is an auto#)
-docname ...........(Description of the doc)
-location ..............(e.g. "images\Power Point\Smart-Wireless-Overview-16x9.pptx")
-typeid (FK).......(e.g. Manual, Presentation, Drawing etc)
-modelcode.........(e.g. 3051S, 3144 etc)
I am building a search field where the user can enter a search criteria and the system should display the document.
I was able to design the search and get accurate results however I am unable to get a clickable link for the user to view or download the document. All that is appearing on the browser is the actual link stored in the DB.
Is there any way for me to get a link or icon for the user to click to view the document?
------SEARCH CODE------
<h2>Select A Search Criteria</h2>
<div id="search_options">
<form name="form1" method="post" action="Result.asp">
<label for="input"></label>
<input type="text" name="input" id="input">
<input type="submit" name="search_btn" id="search_btn" value="Submit">
</form>
</div>
------RESULTS CODE------
<h2>Content Found</h2>
<div id="results">Content for id "results" Goes Here
<% If Not Search.EOF Or Not Search.BOF Then %>
<table border="1">
<tr>
<td>refid</td>
<td>docname</td>
<td>location</td>
<td>typeid</td>
<td>modelcode</td>
<td>Details</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT Search.EOF)) %>
<tr>
<td><%=(Search.Fields.Item("refid").Value)%></td>
<td><%=(Search.Fields.Item("docname").Value)%></td>
<td><%=(Search.Fields.Item("location").Value)%></td>
<td><%=(Search.Fields.Item("typeid").Value)%></td>
<td><%=(Search.Fields.Item("modelcode").Value)%></td>
<td> View</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Search.MoveNext()
Wend
%>
</table>
<% End If ' end Not Search.EOF Or NOT Search.BOF %>
</div>
</section>
-----DETAILS CODE-----
<p>Content for id "results" Goes Here</p>
<p><img src="images/Data_Sheets/00813-0100-4001.pdf" width="82" height="73" longdesc="<%=(Details.Fields.Item("location").Value)%>"></p>
<p><%=(Details.Fields.Item("location").Value)%></p>
</div>
</section>
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()
I have created web user control for calendar. I.e it has a textbox and a calendar image. By clicking on calendar popup the calendar opens. Then by selecting any date it stores the year of that date. I use this code:
<script language="javaScript" type="text/javascript" src="Scripts/Calendar.js"> </script>
<link href="Styles/Calendar.css" rel="stylesheet" type="text/css" />
<table>
<tr>
<td>
<input type="text" name="datum1"/>
</td>
<td>
<img id="Img1" src="images/calFinal.jpg" alt="" runat="server" onclick="setYears(1947, 2040);
showCalender(this, 'datum1');" />
</td>
</tr>
</table>
<div>
<!-- Calender Script -->
<table id="calenderTable">
<tbody id="calenderTableHead">
<tr>
<td colspan="4" align="center">
<select onchange="showCalenderBody(createCalender(document.getElementById('selectYear').value,
this.selectedIndex, false));" id="selectMonth">
<option value="0">Jan</option>
<option value="1">Feb</option>
<option value="2">Mar</option>
<option value="3">Apr</option>
<option value="4">May</option>
<option value="5">Jun</option>
<option value="6">Jul</option>
<option value="7">Aug</option>
<option value="8">Sep</option>
<option value="9">Oct</option>
<option value="10">Nov</option>
<option value="11">Dec</option>
</select>
</td>
<td colspan="2" align="center">
<select onchange="showCalenderBody(createCalender(this.value,
document.getElementById('selectMonth').selectedIndex, false));" id="selectYear">
</select>
</td>
<td align="center">
<font color="#003333" size="+1">X</font>
</td>
</tr>
</tbody>
<tbody id="calenderTableDays">
<tr style="">
<td>Sun</td>
<td>Mon</td>
<td>Tue</td>
<td>Wed</td>
<td>Thu</td>
<td>Fri</td>
<td>Sat</td>
</tr>
</tbody>
<tbody id="calender">
</tbody>
</table>
<!-- End Calender Script -->
</div>
The problem occurs when I use the user control twice on the same web form. I have registered the control. When I use it once, it works proper. But I want it at two places. So, please give some solution on how to use the user control more than one time on the same web form. I have given different IDs for the user control, but it still does not work.
Code for user control:
<tr>
<td class="directorytdWidth directorylabel">
School Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtSchoolName" runat="server" Width="120px" ForeColor="#FF9F00"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth directorylabel">
School Passout Year:
</td>
<td class="directoryTdPadding">
<uc1:calendar ID="schoolPassout" runat="server" />
</td>
</tr>
<tr>
<td class="directorytdWidth directorylabel">
College Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCollegeName" runat="server" Width="120px" ForeColor="#FF9F00"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth directorylabel">
College Passout Year:
</td>
<td class="directoryTdPadding">
<uc1:calendar ID="collegePassout" runat="server" />
</td>
</tr>
Use the Same User control but With diferent ID. For example (See code below)
Reg Your User control in you Web page
<%# Register Src="~/Controls/SearchAffiliated.ascx" TagPrefix="uc" TagName="SearchAffiliated" %>
First User Control call
<uc:SearchAffiliated runat="server" ID="ucSearchAffiliated" />
Second User Control Call
<uc:SearchAffiliated runat="server" ID="SearchAffiliated1" />
See The Users Controls have diferents IDs, That Works For call The same UC in one web form.
Cheers.
Use the loop of how many times that u want the usercontrol to display:
for(int i=0;i < n; i++) //Define the number of time that u want to display
{
usercontrolname.id="UC"+i;//Assign the id for that usercontrol
//add line of code,that controls in placeholder or panel
}
You can use same user control in same page in N number of times. either it dynamically or statically. Only the thing is we need to give the different ID for the usercontrol
This need to add in your Reg
<%# Register Src="~/UserControls/Hello.ascx" TagPrefix="uc" TagName="Hello" %>
calling the user control 1
<uc:Hello runat="server" ID="ucHello1" />
calling the user control 2
<uc:Hello runat="server" ID="ucHello2" />
I faced same problem but the problem was not related with the ID you prefer to use inside the asp.net page. Because I guess asp.net automatically generates ID for each element in page if it doesn't have one.
The problem was I copied ascx files and forget to change their class names. Make sure you use different class names for each user control.
<%# Control Language="C#" ClassName="ucSchema2" %>
I know this i late to the game but maybe someone can use this answer anyway.
Using a static clientside id for a html element in a user control and then using that user control multiple times will results in invalid html.
You are only allowed to use an id once on a html page otherwise getElementById (which returns a single element) will not know which element to get and then you will probably not get any element whatsoever.
You need to make those clientside ids inside the user control truely unique, i.e. selectMonth, selectYear.
This might be done by appending the ClientID of the user control to the element id. Something like this (not sure if this approach really works but you get the idea):
<select onchange="showCalenderBody(createCalender(document.getElementById('selectYear_<%=this.ClientID%>').value,
this.selectedIndex, false));" id="selectMonth_<%=this.ClientID%>">
This way the clientside id should be a combination of locally unique ids and the page unique control ids.
I am trying to retreive pull up the following:
<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">
<a href="http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNEjddVUpIXf528-P5S0D0z5A0_QjQ&url=http://www.daytondailynews.com/news/news/local/letter-points-to-plumbing-in-2011-legionnaires-out/nSmCp/">
<b>Letter points to plumbing in 2011 <b>Legionnaires</b>' outbreak at hospital</b></a><br /><font size="-1">
<b><font color="#6f6f6f">Dayton Daily News</font></b></font><br />
<font size="-1">A letter entered into court records identifies for the first time several factors that may have caused an outbreak of <b>Legionnaire's disease</b> in Miami Valley Hospital's new 12-story patient tower shortly after it opened in late 2010. The outbreak, at 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=dRROval94f0jKyM&ned=us"><nobr><b></b></nobr></a></font></div></font>
</td>
</tr>
</table>
Which is formatted in html on my .aspx page.
I am doing the following:
<%# XPath("description").ToString()%>
but it is not showing me the html rendering of it. What I like to show it to me converted into HTML.
as description is already in HTML, why is it not showing it to me?
Use Literal Control
<asp:Literal id="Literal1" runat="server" text='<%# XPath("description").ToString() %>' />
In a specific screen I need to let the user print out some data. Due to the complexity of the data displayed, it is used a label:
lblTree.Text = stringHTML;
The tree is displayed using a dynamically constructed HTML string. The final string is 52 000 characters long. I don't think that is important, but I thought I would explain the background.
In aspx, it looks like this:
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="left" class="PrintTBLHeader"><br />report as of 20/09/2012 : <br /><br /></td>
</tr>
<tr>
<td colspan="3"><br /><asp:Label runat="server" ID="lblTree"></asp:Label><br /><br /></td>
</tr>
<tr>
<td colspan="3" align="left" class="PrintTBLHeader"><br />2nd title:<br /><br /></td>
</tr>
<tr>
<td colspan="3"><br /><asp:Label runat="server" ID="lblMPMtree"></asp:Label></td>
</tr>
</table>
The problem is this:
when I open the print preview, it should say 6 pages (like in firefox and chrome - those are working right), but this print preview from IE8 is showing me only 3 pages.
lblTree is cut at the end of the 1st page
Then on the second page, instead of showing the rest of lblTree, it starts with the "2nd title" (tr #3 in the example above)
I found some article related to something like this, where the solution was adding media="print" to the <link>.
<link rel="stylesheet" type="text/css" href="..." media="print" />
That did not work.
To summarize:
Check the code if it's invalid to the DOCTYPE with the validator
If invalid, IE will render in quirksmode which is never a good thing.