I want to take the "total member" number (on the right bar of the website) and display that number inside a label in C# windows form application. Here is the website: https://www.dojrp.com/
Thanks
Here is a solution to solve your problem:
Step 1. Get the html code of this website page using System.Net.WebClient class.
Step 2. Locate the "total member" number in the html code and get it using System.Text.RegularExpressions.Regex class.
Step 3. Assign that number to your label on your windows form.
Related
I am currently trying to integrate a weather module into my software from a freely available source and i can get my form to load if i write the code as follows:
WebBrowser1.DocumentText = "<html><img src=http://www.7timer.info/bin/astro.php?lon=-2.36&lat=55.91&lang=en&ac=0&unit=metric&tzshift=0 </html>";
What i want to do however is be able to dynamically alter the html code by using global variables defined in the parent form to insert the corrected lattitude and longitude into the code. The idea being that the user can enter their Lat/Lon on the parent form where it is used for other purposes but those values will then be the base for generating a corrected local weather forecast.
The code i have to do this is:
string myweather = "<html><img scr=http://www.7timer.info/bin/astro.php?lon=" + Global_Variables.Longitude + "&lat=" + Global_Variables.Lattitude + "&lang=en&ac=0&unit=metric&tzshift=0 </html>";
WebBrowser1.DocumentText = myweather;
Method 1 works just fine and the form populates with the weather forecast but when i use method 2 the form is always blank. I have used the debugger and written out the value generated by metho2 2 and it returns exactly the same as what was defined in method 1. I have tried various iterations such as
WebBrowser1.DocumentText = (char)34+myweatheer+(char)34
and also having it as a variable instead of a string but nothing i seem to do makes any difference and the (char)34 method only drops quotation marks into the form with a gap inbetween and the rest of the form is blank. I really cant understand how a different method that returns exactly the same value does not seem to work?
There is literally no more code within the form itself as it's only purpose is to be a pop up child form that displays a graphical weather forecast. When a button is clicked on the parent form then this one opens up and contains only a web browser container with this html code inserted into the container. If i go to the website referenced in the code there are option for setting parameters and generating the html string that can be copied and pasted into your own website if you wish. Alternately you can write your own string in the correct format to make the same query and return an image with the weather forecast. In fact if i take the resulting output of "myweather" without the "" and paste it into a web browser i do actually get the web browser showing exactly the image i am expecting. I have edited the original post to be clearer as to the default container name instead of my custom name.
I'm working on a project in c# .net where I have a website, on the page is a textbox
I have some qr codes that link to this page
when a particular qr code must fill in a text box.
it is possible to write a ULR that can automatically fill in the textbox
ex page.com(insert to tbxOne:"123")
How are you getting the QR codes?
Without code I can't be too much help but you could try come if the following things.
Document.getelementbyid(#id).innerhtml("text");
This will allow you to set the text of an element on the webpage.
https://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid(v=vs.110).aspx
I'm making an application that can find an item on a website if the item name and colour matches the one set inside the application.
If the item name is set as "backpack" and colour set as "green" the application should find a match on the page and click the link. The website is this: Click
I would prefer doing this in C# with http requests or something similar. I would also do PhantomJS if anyone has a better solution using it.
You can use selenium, it basically allows you to act like a user with actual web browser. http://www.seleniumhq.org/
You can do something like mentioned below with the help of XPath:
driver.Navigate().GoToUrl("http://www.supremenewyork.com/shop/all/bags");
var backpack= driver.FindElement(By.XPath("//*[contains(#class,'inner-article')]//h1//a[contains(., 'Backpack') or contains(., 'Backpack')]"));
var colorGreen = driver.FindElement(By.XPath("//*[contains(#class,'inner-article')]//p//a[contains(., 'Acid Green') or contains(., 'Acid Green')]"));
if (backpack.Text == "Backpack" && colorGreen.Text == "Acid Green")
colorGreen.Click();
It is a tested code, it successfully finds the required values within tags, clicks and moves to that page.
Hope it helps.
We have a page(URL 2) which is embedded or loaded in Div element(Popup) of another page(master page) when a button is clicked on master page(URL 1).
I am not able to access the elements on this embedded page.
The firepath developer plugin shows, there are two objects (Top Window URL 1 and another with different URL 2). When I try to highlight any element with xpath locator on page 2 URL 2, its not successful as the object/document selected is Top Window. In order to access elements on page 2, the document needs to be changed.
Tried using SwitchTo method but no luck. The embedded page is niether loaded in a separate window nor in Iframe.
SwitchTo method can only be used if another window is opened or Iframe is present on page.
Does anyone have any ideas or solutions to change the document context so that all new commands are sent to this new page 2.
I am using C# bindings v2.53.
Thanks in advance.
Try to use:
driver.SwitchTo().Window(driver.WindowHandles.ToList().Last());
I got the problem and eventually answer to that.
Its really simple. Its simply working out with jquery.
{driver.executeScript("return $('body /deep/ <#yourSelector>')}
this piece of code simply draws the element from shadow DOM and which can be further used to simulate user actions... :)
OK I'm new to DotNetNuke and need to write a simple module in DNN that will display an article for everyone, and allow the admin to edit the article/add a new one.
I have a test page that contains a DNN module with one module definition and two controls in that definition. The default control shows the article based on an articleID field in the querystring. You then click a button that is supposed to load the edit control and pass the articleID in the query string.
If I use EditURL() in the onClick the edit control is loaded with the correct articleID, but using the admin skin. If I use Globals.NavigateURL() then the correct skin is shown but my edit control isn't loading in the page.
Any clue as to how to what I'm doing wrong or how to get the edit control loading with the correct skin?
My two methods of switching to the edit control (in my button click event) are listed below:
string newURL = this.EditUrl("articleID", Request.QueryString["articleID"], "EditArticle");
Response.Redirect(newURL);
and
string newURL = Globals.NavigateURL(this.TabId, "EditArticle","articleID="+Request.QueryString["articleID"]);
Response.Redirect(newURL);
Actually you are doing this correctly - the editurl in DNN does load the Admin skin - usually this skin is based on someone administering content so it strips out all other modules and shows the 'basics'. Right or wrong this is what it does.
If you dont want to to do that you could provide a switch in the querystring and show a seperate panel or do a multiview control and show different views based on the switch in the query string.
There are a few other approaches like changing the content area to editing text area with ajax or using popup modal style windows.