I'm trying to create an excel spreadsheet with a landing page where I input a specific week number, period number and/or year.
I would then click a button to open an instance of Internet Explorer, navigate to the web form, input the data from the cells in the spreadsheet and then load up the reports selected.
Code for the web form
<br>
<body>
</body>
</html>
<head>
<!--include file="../../Connections/SQL.asp" -->
<title>Performance Reporting</title>
<link href="../../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<link href="../../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<link href="../CSS/KPI_Style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style45 {color: #990000}
-->
</style>
<script type="text/javascript" language="javascript">
<!--
function makeDisable(){
var y=document.getElementById("store")
var x=document.getElementById("CHNSplits")
if (y.value=='CP11')
{
x.disabled=true
}
}
function makeEnable(){
var x=document.getElementById("CHNSplits")
x.disabled=false
}
-->
</script>
</head>
<body>
<div align="center">
<link href="../CSS/PL_Style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {font-size: 16px}
.style33 {color: #ffffff}
-->
</style>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#001446" class="border9"><div align="left"><img src="80.gif" alt="DSGi" /></div></td>
<td valign="bottom" bgcolor="#001446" class="border16"><div align="right" class="xbig style1 style33"><span class="style2">Store Performance</span> </div></td>
</tr>
</table>
<br>
<br>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: url();
}
.style1 {
color: #d33;
font-size: 18px;
}
.style2 {color: #000000; font-size: 2px; }
.style10 {color: #d33}
.style15 {font-size: 12px}
-->
</style>
<title></title>
</div>
<link href="../../../Testing/KPI/NewKPI/Digital_KPI/stylesheet.css" rel="stylesheet" type="text/css">
<div align="center"><span class="reportname"> Reporting Selection</span></div>
<form name="form1" id="form1" method="post" action="Get_Page_V4.asp">
<input name="store" type="hidden" value="2397" >
<input name="ViewType" type="hidden" value="store" >
<table width="60%" border="1px" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<td colspan="2"><div align="center" class="formnamesmall">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr height="4">
<td></td>
</tr>
<tr height="5">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="6"><div align="center" class="formtextverylarge">Selected Location:</span> 1111</div></td>
</tr>
<tr>
<td><input name="RadioGroup1" type="radio" value="1" checked></td>
<td class="formnamesmall" ><strong>Yesterday</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><input type="radio" name="RadioGroup1" value="2"></td>
<td class="formnamesmall" ></td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall"> </td>
<td class="formtext">
<input name="datebox" type="hidden" id="datebox" value="07/10/2018" size="10" maxlength="10"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr>
<td><input type="radio" name="RadioGroup1" value="3"></td>
<td class="formnamesmall" ><strong>Week</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Week </td>
<td class="formtext">
<input name="week" type="text" id="week" value="24" size="2" maxlength="2"></td>
</tr>
<tr>
<td> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="weekyear" type="text" id="weekyear" value="2019" size="4" maxlength="4"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><label>
<input type="radio" name="RadioGroup1" value="4">
</label></td>
<td class="formnamesmall" ><strong>Period</td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Period </td>
<td class="formtext">
<input name="period" type="text" id="period" value="6" size="2" maxlength="2"></td>
</tr>
<tr class="formtext">
<td> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="periodyear" type="text" id="periodyear" value="2019" size="4" maxlength="4"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr height="15">
<td height="10"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
<td height="10" class="formtext"></td>
</tr>
<tr class="formtext">
<td><input type="radio" name="RadioGroup1" value="6"></td>
<td class="formnamesmall" ><strong>Year </td>
<td class="formtext"> </td>
<td class="formtext"> </td>
<td class="formnamesmall">Enter Financial Year </td>
<td class="formtext">
<input name="YearYear" type="text" id="YearYear" size="4" maxlength="4" value="2019" ></td>
</tr>
<tr><td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
</tr>
<!--
<tr>
<td colspan="4"><div align="center"><span class="formnamesmall style45">Select Report Type</span></div></td>
<td> </td>
<td colspan="2" class="formname" ><strong></td>
</tr>
-->
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<td height="10"> </td>
<tr>
<!--
<td><div align="center">
<input name="RadioGroup2" type="radio" class="Style10" value="1" >
</div></td>
<td>
<div align="right" class="formnamesmall style45">
<div align="left">Charts </div>
</div></td>
-->
<input name="RadioGroup2" type="hidden" class="Style10" value="6" checked="Checked">
<!--
<td><div align="right" class="formnamesmall">
<div align="left" class="style45">League Tables
</div>
</div></td>
-->
<td class="formnamesmall" colspan="4"> </td>
<td><input type="submit" name="Submit" value="Display Report"></td>
</tr>
</table>
<p> </p>
</div></td>
</tr>
</table>
<input name="page_name" type="hidden" value="Region_Page1_" />
</form>
<br>
<br>
<style type="text/css">
<!--
.style1 {
font-size: 10px;
color: #FFFFFF;
}
-->
</style>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom" bgcolor="#001446"><div align="right" class="xbig style1 style1"> </div></td>
</tr>
</table>
</body>
VBA code
Sub Get_Data()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim dates As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://INTRANETSITE/Summary_Select.asp"
Do Until .readyState = 4 And Not .Busy
DoEvents
Loop
.document.all.Item("radioGroup1")(3).Checked = True 'Select the 4th checkbox down on the list
.document.forms(0).submit 'Submit the form to generate the result
End With
Pause (2)
With IE
.navigate "http://INTRANETSITE/ReportDetail2.asp?"
Do Until .readyState = 4 And Not .Busy
DoEvents
Loop
End With
End Sub
The code above navigates to the web form and does select the 4th radio button which is for period reports, then submits the form and displays the first page.
How do I interact with the text boxes to also amend which week or period I want to select reports for?
Also, when it tries to navigate to ReportDetail2.asp it returns the following error and then crashes the VBA code.
Method 'Navigate' of object 'IWebBrowser2' failed
The long term goal of this is to navigate through 20+ pages of reports, pulling the data from each table into a tab on the spreadsheet, so if it can't navigate between the reports, even before we get to the code to pull the data, then that's a problem.
Try something like the following. I am showing the different options you might consider so remember to comment out those you don't want to use.
You need to add a reference to Microsoft Internet Controls via VBE > Tools > References or use late bound call of
Dim ie As New InternetExplorer : Set ie = CreateObject("InternetExplorer.Application")
VBA:
Option Explicit
Public Sub MakeSelections()
Dim ie As New InternetExplorer
Const URL As String = "yourURL"
With ie
.Visible = True
.navigate URL
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
.querySelector("[value='1']").Checked = True 'Yesterday. CSS attribute = value selector
.querySelector("[value='3']").Checked = True 'Week
.querySelector("[value='4']").Checked = True 'Period
.querySelector("[value='6']").Checked = True 'Year
.getElementById("week").Value = 6 'week value
.getElementById("weekyear").Value = 2018 'financial year value
.getElementById("period").Value = 6 'period value
.getElementById("periodyear").Value = 2018 'period financial year value
.getElementById("yearyear").Value = 2019 'financial year value
.querySelector("[value='Display Report']").Click 'display report
End With
Stop '<== Delete me later
'.Quit '<== Remember to quit application
End With
End Sub
Related
I'm trying to build a table in my email host for a future marketing email and I'm so darn close to finishing it up - but there's one last item that's stumping me. I'm trying to find a way to remove the extra spacing between the bullets - I know the text itself is single spaced like I want, but I don't want there to be double spacing of sorts between text items or bullets. Is there a small bit of code I can add into the below to adjust spacing between bullets to single or perhaps 1.5x?
<table>
<tbody>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:normal"><span style="font:14px arsenal"><span
style="color:#86c8c5">Cruelty Free</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:normal"><span style="font:14px arsenal"><span
style="color:#86c8c5">Vegan Friendly</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:1"><span style="font:14px arsenal"><span
style="color:#86c8c5">Refillable Bottle for Life</span></span>
</span>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
<tr>
<td width="55"> </td>
<td style="vertical-align: top"><span style="line-height:1"><img height="30"
src="https://i.postimg.cc/52RGgKNg/63724-MYK-PP-Email-Announcement-02.png
" width="30" /></span></td>
<td width="20"> </td>
<td><span style="line-height:1"><span style="font:14px arsenal"><span
style="color:#86c8c5">Soothing Yuzu and<br />
Rice Water Formula</span></span>
</span>
</td>
</tr>
</tbody>
</table>
I have a questions about how to loop through a html tab 'form' or 'Table Summary'.
The site : Visit https://mobile.uwants.com/forumdisplay.php?fid=631
I have tried below code but no luck
start_urls = ['https://mobile.uwants.com/forumdisplay.php?fid=631'])
def parse(self, response):
resp =response.xpath("//*[//*[#id='mainbody']/tbody/tr/td/div/table[2]/tbody/tr/td[1]/div[2]/form")
for r in resp:
r = response.xpath('//*[contains(#id,"thread_197")]/a/#href').extract_first()
yield response.follow(r,self.parse_items)
The first image is that this is my initial table that i would like the problem to loop through each comments
The second image is that this is one of the sample that i would like to scrap the comment
HTML Code
<form method="post" name="moderate" action="topicadmin.php?action=moderate&fid=631">
<input type="hidden" name="formhash" value="df27712a" />
<table summary="forum_631" cellspacing="0" cellpadding="0">
<thead class="category">
<tr>
<td class="folder"> </td>
<td class="icon"> </td>
<th>標題</th>
<td class="author">作者</td>
<td class="nums">回覆/查看</td>
<td class="lastpost">最後發表</td>
</tr>
</thead>
<tbody>
<tr>
<td class="folder"><img src="https://n2.hk/images/default/folder_common.gif" alt="announcement" /></td>
<td class="icon"> </td>
<th class="tsubject">論壇公告: 開戰準備!全新版區《Gundam Fan Club》開放!</th>
<td class="author">
<cite>mhmimi</cite>
<em>2017-6-9</em>
</td>
<td class="nums">-</td>
<td class="lastpost">-</td>
</tr>
</tbody>
<!-- Text T4 - Modified by Ivan - start-->
<tbody>
<tr>
<td colspan="6" height="35"><!-- Ad space:Uwants_Web_630_T4 --><script src="https://lv.l.networld.hk/lview?loc=_adb_20_10002834&callback=crystal2.addStaticSlot"></script>
</td>
</tr>
</tbody>
<!-- Text T4 - Modified by Ivan - end-->
<tbody id="stickthread_19434311" class="forumdisplay_thread" data-tid="19434311">
<tr>
<td class="folder"><img src="https://n2.hk/images/default/folder_lock.gif" /></td>
<td class="icon">
</td>
<th class="lock">
<label>
<img src="https://n2.hk/images/default/pin_2.gif" alt="分類置頂" />
<!-- By Rex Heat Thread -->
<!-- By Rex Heat Thread -->
</label>
<span id="thread_19434311" class="tsubject"><!-- google_ad_section_start -->請各會員注意,本版新措施(已生效)<!-- google_ad_section_end --></span>
</th>
<td class="author">
<cite>
Yue33695874
</cite>
<em></em>
</td>
<td class="nums">
<strong>0</strong> / <em>41262</em>
</td>
<td class="lastpost">
<em></em>
<cite>by Yue33695874 </cite>
</td>
</tr>
</tbody> <tbody id="stickthread_16031523" class="forumdisplay_thread" data-tid="16031523">
<tr>
<td class="folder"><img src="https://n2.hk/images/default/folder_lock.gif" /></td>
<td class="icon">
</td>
<th class="lock">
<label>
<img src="https://n2.hk/images/default/pin_2.gif" alt="分類置頂" />
<!-- By Rex Heat Thread -->
<!-- By Rex Heat Thread -->
</label>
<span id="thread_16031523" class="tsubject"><!-- google_ad_section_start -->==手機網絡 版版規== 本版嚴禁一切問價及報價, 違者發帖將被移走及不作通知!<!-- google_ad_section_end --></span>
</th>
<td class="author">
<cite>
quimboy1
</cite>
<em></em>
</td>
<td class="nums">
<strong>0</strong> / <em>61033</em>
</td>
<td class="lastpost">
<em></em>
<cite>by quimboy1 </cite>
</td>
</tr>
</tbody> <tbody id="stickthread_16776292" class="forumdisplay_thread" data-tid="16776292">
<tr>
<td class="folder"><img src="https://n2.hk/images/default/folder_lock.gif" /></td>
<td class="icon">
</td>
<th class="lock">
<label>
<img src="https://n2.hk/images/default/pin_1.gif" alt="本版置頂" />
<!-- By Rex Heat Thread -->
<!-- By Rex Heat Thread -->
</label>
<span id="thread_16776292" class="tsubject"><!-- google_ad_section_start -->溫馨提示 : 小心網上流動手提電話公司sales, 已經有騙案個案及已轉交警方處理<!-- google_ad_section_end --></span>
</th>
<td class="author">
<cite>
chungsm
</cite>
<em></em>
</td>
<td class="nums">
<strong>2</strong> / <em>65809</em>
</td>
<td class="lastpost">
<em></em>
<cite>by chungsm </cite>
</td>
</tr>
</tbody><!--
</table>
<table summary="forum_631" id="forum_631" cellspacing="0" cellpadding="0">
-->
手機網絡 - 熱門話題
</td></tr></tbody-->
<!--td class="folder" colspan="2"> </td-->
<td class="folder" ><img src="https://n2.hk/images/r09/hot_u.gif" /></td>
<td class="icon"> </td>
<th class="" >
<label>
<!-- By Rex Heat Thread -->
<!-- By Rex Heat Thread -->
</label>
<span id="thread_ht_1_19782731" class="tsubject">問 : 中國移動4.5G 網絡 地鐵接收如何</span>
New
Thanks for help guys
Try to change this line:
r = response.xpath('//*[contains(#id,"thread_197")]/a/#href').extract_first()
With this:
r = r.xpath('//*[contains(#id,"thread_197")]/a/#href').extract_first()
I think this is what you meant to do!
If you want to fetch all href contained in the table, you can do:
response.css('.tsubject a::attr(href)').extract()
I would like to toggle selection between two different sets of radio buttons.
The condition that must be met is that if the user checks the button on one set (called in the example l1), it is unchecked in the other set (called in the example m1).
In other questions, it seems that it is only feasible solution is using Java scripts.
Below is the code:
<table border="0" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td style="width: 300px;"> </td>
<td style="width: 100px; text-align: center;">Least</td>
<td style="width: 100px; text-align: center;">Most</td>
</tr>
<tr>
<td>{{question1}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-1" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="1" /></td>
</tr>
<tr>
<td>{{question2}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-2" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="2" /></td>
</tr>
<tr>
<td>{{question3}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-3" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="3" /></td>
</tr>
<tr>
<td>{{question4}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-4" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="4" /></td>
</tr>
</tbody>
I'd like to know where i have gone wrong, i want to apply font verdana to "to change this font to verdana."
I have removed contend from other table rows to make the code appear clearer. I have set the css styling to this section but when uploading the font does not change at all.
Code is:
<style type="text/css">
#form1 tbody tr td {
font-family: Verdana, Geneva, sans-serif;
}
</style>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<tr>
<td><strong>Title 1</strong></td>
</tr>
<tr>
<td>To Change this font to verdana.<br>
<br></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</form>
<tr>
<td>
<!-- start here-->
<form action="http://www./cookie5payment/freecontact2formprocess.php" method="post">
<table class="freecontact2form" border="0" width="400px">
<tbody>
<tr>
<td colspan="2"><span style="font-size: x-small;"> </span> <br /> <br /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><br></td>
<td></td>
</tr>
<tr>
<br>
<td valign="top"> </td>
</tr>
<tr>
<td style="text-align:center" colspan="2"><br /><br />
<br /><br />
<br /><br /></td>
</tr>
</tbody>
</table>
</form>
<!-- end here -->
</td>
</tr>
</table>
</tr>
Your code is not working as expected because you use the identifier #form1 to target the table inside that form, but you start the table outside the form so the css selector can not find it. Change the order of your html as follows (i.e. switch the form and table tag)
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1 id="form1">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
Here is a fiddle to illustrate this
I have the following table which sits inside an asp.net form. Im trying to process it using an onclick event on a button. but the elements are html text boxes and html check boxes all with names that are arrays
ive tried doing this
for(int i = 0; i < Request["pageimagesOrder"].Length; i++)
{
Response.Write(Request["pageimagesOrder"][i]);
}
but it just fell over. Im sure its something simple but like all things, there only simple if you know
thanks
<table>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/1.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[1]" value="1 "></td>
<td width="100" valign="top"><input type="checkbox" value="1" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/2.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[2]" value="2 "></td>
<td width="100" valign="top"><input type="checkbox" value="2" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/3.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[3]" value="3 "></td>
<td width="100" valign="top"><input type="checkbox" value="3" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/5.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 1</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[5]" value="4 "></td>
<td width="100" valign="top"><input type="checkbox" value="5" name="pageimagesDelete[]" /></td>
</tr>
<tr>
<td width="200"><img src="/CaptionImages/Thmbs/7.png" width="196" height="140" /></td>
<td width="300" valign="top">caption txt 2</td>
<td width="25" valign="top"><input style="width:20px;" type="text" name="pageimagesOrder[7]" value="5 "></td>
<td width="100" valign="top"><input type="checkbox" value="7" name="pageimagesDelete[]" /></td>
</tr>
</table>
You are actually naming them with the brackets []
If you write
Response.Write(Request["pageimagesOrder[1]"]) in code behind you will get a value.
You'll need to do:
Response.Write(Request["pageimagesOrder[" + i + "]"]);
That'll give you the correct naming :)