How to use a question mark in url? - javascript

Here's my question: How to use a question mark in url ?
For a school project I need to use "?version=1", "?version=2" and "?version=3" in my url for 3 different versions of a website but after some researches, I found that the ? is used to pass a query string and use it in server-side but I haven't found more informations or doc.
My problem is that we don't have server for the project and I would know if I can still the question mark and if it's possible to use it in Javascript in order to display specific elements on the page according to the version of the website I'm using.
Thanks !

You can still use the query string (?version=1) without having access to the server. Just capture the value using the method Austin linked and go from there.

Related

I need to get an Instagram User ID# for use in Google Script

I'd like to take a username and plug it into this format
https://www.instagram.com/{username}/?__a=1
thanks to this thread for that tip
I then need to follow that link in java, and when doing so it presents the following page code, which I've abridged to save space. I used professional Skateboarder Nyjah Huston as my example.
{"logging_page_id":"profilePage_8223552","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"Sender\ud83d\ude08\n#nikesb #monsterenergy #elementbrand #blackplaguebrewing #socialcbd #priverevaux","blocked_by_viewer":false,"restricted_by_viewer":null,"country_block":false,"external_url":"https://www.nike.com/t/sb-nyjah-free-skate-shoe-oKwn7N/AA4272-300","external_url_linkshimmed":"https://l.instagram.com/?u=https%3A%2F%2Fwww.nike.com%2Ft%2Fsb-nyjah-free-skate-shoe-oKwn7N%2FAA4272-300&e=ATMW9Q8NwN2Mcwm_Bd5I8DeuAKP4L7IHpy_PdylDnGU8qqokJU6Z1kh_emEIVfJ1q8Xtq1b0&s=1","edge_followed_by":{"count":3969537},"followed_by_viewer":false,"edge_follow":{"count":694},"follows_viewer":false,"full_name":"Nyjah Huston"
As you can see, the User ID is one of the first things on the page
{"logging_page_id":"profilePage_8223552"
the user id being 8223552 in this case. I'm quite new to java, and I need to know how to follow that link and parse that data in order to turn the user id into a var for use in my google script. Thank you for your help!
You can easily parse this JSON content to a object that has only the information you need:
class UserInformation{
private String logging_page_id;
}
I suggest this option because if you need in the future to get another info, you can easily just extend the object.
How to do the conversion, please reference to this stackoverflow

Run Database Stored RegEx against DOM

I have a question about how to approach a certain scenario before I get halfway through it and figure out it was not the best option.
I work for a large company that has a team that creates tools for the team mates to use that aren’t official enterprise tools. We have no access to the database directly, just access to an internal server to store our files to run and be able to access the main site with javascript etc (same domain).
What I am working on is a tool that has a ton of options in it that allow you to select that I will call “data points” on a page.
There are things like “Account status, Balance, Name, Phone number, email etc” and have it save those to an excel sheet.
So you input account numbers, choose what you need and then using IE Objects it navigates to the page and scrapes data you request.
My question is as follows..
I want to make the scraping part pretty Dynamic in the way it works. I want to be able to add new datapoints on the fly.
My goal or idea is so store the regular expression needed to get the specific piece of data in the table with the “data point option”.
If I choose “Name” it knows the expression for name in the database to run again the DOM.
What would be the best way about creating that type of function in Javascript / Jquery?
I need to pass a Regex to a function, have it run against the DOM and then return the result.
I have a feeling that there will be things that require more than 1 step to get the information etc.
I am just trying to think of the best way to approach it without having to hardcode 200+ expressions into the file as the page may get updated and need to be changed.
Any ideas?
IRobotSoft scraper may be the tool you are looking for. Check this forum and see if questions are similar to what you are doing: http://irobotsoft.org/bb/YaBB.pl?board=newcomer. It is free.
What it uses is not regular expression but a language called HTQL, which may be more suitable for extracting web pages. It also supports regular expression, but not as the main language.
It organizes all your actions well with a visual interface, so you can dynamically compose actions or tasks for changing needs.

Extract search engines' keywords with javascript and HTTP referer

I can't find anything googling. How can I extract search engine keywords for traffic sent to my website using javascript?
I don't want to reinvent the wheel, I'm looking for something that already exists, a tested library, however I can't find it.
As an answer, rather than just a comment. Your javascript code will need to inspect document.referrer (This may have been the magic keyword missing from your search).
Different search engines use different parameter names for the query, so you will need to know what to look for. Google uses q Yahoo! appear to use pqstr. Look for the value of that parameter in the referring url, and unencode it (with unencodeURIComponent).
However, there is still this answer to check out.

Adapting Etherpad to react on new params

I try to adapt etherpad so it is only accessible if certain params are sent with the request.
For example I want a certain pad just to be displayed if there is a unique id provided like
http://myetherpad.com/thepadid?myparam=blub
Does anyone know where exactly I can parse the params? I searched all the js-files but didn't find exactly what I am looking for.
I found out that there is some kind of request object. You can access it like
request.params.padId
But I also don't know where to search for the implementation of this object.
I hope somebody can help me. Thanks :)
You could probably hack something into the code at https://github.com/ether/pad/blob/master/etherpad/src/etherpad/licensing.js#L153
But if all you need is some kind of password protection, there are easier ways. The easiest would be to use something that is built in to your web server, or to use the built-in pro functionality -- more on that on http://etherpad.org/2010/10/14/241/
(Your idea with using URL-parameters for password could be simplified; just use a complicated pad name and only those with the URL will find it. Having a "nice" pad name and adding a complicated password at the end doesn't protect the pad at all.)
For anyone with the same problem: You can get the GET-parameters via
request.headers['Referer']
It returns the URI the user called. But I still don't know how to do it properly (or get the POST parameters).

Does Google index content generated using javascript?

does Google index content generated using javascript I'm using this function to write the text
document.write(String.fromCharCode(...))
something like that
document.write(String.fromCharCode(60,112,62,65,100,100,32,100,101,115,99,114,105,112,116,105,111,110,32,102,111,114,32,121,111,117,114,32,65,114,116,105,99,108,101,32,102,114,111,109,32,104,101,114,101,46,60,47,112,62,10));
and if Google don't index javascript will it regard this code as malicious as this function is also used to generate malicious javascript codes of course I'm not using malicious
Thanks in advance.
Yes/No
Google WILL index content if you give it some hints. For example, you'd need to use the #! format and your URLs need to resolve WITHOUT the #!. Like Twitter:
http://twitter.com#!/oscargodson and http://twitter.com/oscargodson work. Google sees a link to the first link then forwards onto the second.
For random bits of JS though? Most likely not. Google doesn't give out specific details to their algorithm. They have quitely switched to indexing PDFs, Flash, Docs, and more when before they said they didn't. With the rise of JS, i wouldn't be surprised if they officially did tho sometime soon.
Here are Google's docs on it:
http://code.google.com/web/ajaxcrawling/
Yes. As of May of 2014, they publicized their move.
http://googlewebmastercentral.blogspot.com.es/2014/05/understanding-web-pages-better.html

Categories

Resources