Amazon add to cart via Request [closed] - javascript

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Improve this question
we are currently trying to read out maximum order quantity, since there is no option in any Amazon API, so we decided to scrape it in some way.
Keepa has some kind of option which is similar to that we want to achieve, but there is no scalable API available. (Keepa devs told us, there wont be any feature in the near future).
Here is an example:
Amazon has unlimited stock, means you can add 999 to cart and most likely even more
There is no add-to-cart "href" but the whole "buybox" is inside of a tag with an form:
Here is the whole form-tag of the BuyBox
Is there someway without rendering JavaScript to perform such kind of Request to Amazon to simulate a click on the add to cart button?
Thank you guys in advance!

In queries like these, be specific with
URL- you are trying to scrape.
mention the element you are trying to extract.
Share a piece of code, you are facing trouble with.
However, if you are trying to simulate the clicking a button on this website or any other browser like behaviour while scraping. Then, going with the browser-automation libraries with headless capabilities like Puppeteer, Playwright and Selenium are the best options. These libraries automatically renders the script tags. And, you can easily simulate the user-like behaviour like clicking a button in Puppeteer, Clicking the button in Playwright, and Clicking the button in Selenium.

Related

Javascript Alert won't show up [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm trying to "hack" a web app by customizing the login page.
I've succefully been able to change an <img>, but I can't seem to use some js.
Whenever I try a simple alert, it shows up on the source code but won't show up on the page.
I wonder if there's any way they blocked js or if I'm missing something on why my alert won't show up.
Below : screenshot of the img tag i've successfully changed and the js I failed to execute from the firefox dev tools.
Please let me know if you're missing some informations.
EDIT : I think I've gave you all the wrong idea :)
I'm not hacking anything. I have the source code of a huge web app.
Now what I'm trying to do is to customize some part of a page. I edited the source code adding an alert (that should show up and that won't).
Here is a part of my code :
<img id="Img_site" src="/images/custom/Img_site.png" style="margin-left:-40px;"/>
<script type="text/javascript">alert("test js")</script>
If you're trying to "hack" a web app that allows users to enter custom code. There is a good change that the developer of that web app put measures in place so strip any scripting. For example i have an application where users can enter custom markup but i have the below code on the front end to strip any script tags and any code in between them before they get submitted to the server. Then on the server I do the same thing to make sure that no script can be passed to the interface effecting users.
var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
while (SCRIPT_REGEX.test(html_code)) {
html_code = html_code.replace(SCRIPT_REGEX, "");
}
You have to notice that the content is already loaded when you append the script. So it won't excute. If you want inyect javascript code to the web you must use the developer tool.

How to find out what js a site uses? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am looking to develop my personal portfolio site, and would like to implement some sort of 'portfolio of work' area.
I want it to be simple and only display single images, however once the image is clicked a box should expand and show more content, such as design brief, tools used etc..
I have seen some examples of the kind of function I require, like eg http://themeforest.net/item/fraiche-flat-onepage-portfolio-bootstrap-template/full_screen_preview/5351761#portfolio and another here http://wrapbootstrap.com/preview/WB04X111M
I would like to be able to find out what javascript plugins certain sites use so I can experiment with them myself. I have tried viewing the source and looking at the console but I find it difficult.
I have used Firebug and DevTools however I can't seem to figure out what js a carousel uses for example. I am able to view source and look at all the individual files that way. Was wondering if there was an easier way, or a browser add-on that would tell me when viewing the website?
If somebody could point me in the right direction I would be grateful.
There is a very good plugin for firefox called firebug which shows all the JS files loaded for that particular page. In firebug scripts tab you can see that.
chrome comes with developer tools where you can find all the files loaded for that page. You can find this at Tool --> Developer Tools.
Right click, Inspect Element or View Source. Look in head section.
You can also look under the Network and Resources tab in your dev tools in chrome, youll see the request to third party plugins too.
You should use an http sniffer(e.g. Fiddler\HttpAnalyzer etc.) and check what html\js\css etc content is downloaded.
After that, you will need to check the sources and find out how things are done.
As others already suggested - view the page source and try to get desired plugin info from there.
There's also a great Chrome extension that'll allow you to instantly see all the javascript and server-side frameworks that the site runs on, it's called Appspector.

Single Page HTML Site - SEO technique [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I developed a Single Page Responsive Website for my company http://germin8.com/ . Everything is going good however I actually now face a problem with SEO .The site's different sections do not show up in search engine.
I know the cause it being a single page site so not crawler friendly...Inorder to get the URL change I used history pushstate technique and have put href links for menu bar items to sections ..... confused ?? eh
Sample anchor tag outlink ( I thought this is enough for my section to show up in Search Engine :-/ )
a style="text-decoration:none;color:black;padding-left:30px;" class="scrollTo" id="contactUs_Menu"
href="/contact-us">CONTACT</a></li>
Or you may have a look at the source code of the website and follow the anchor tags.
On some research and POC I came across this AJAX crawlable technique by google (https://developers.google.com/webmasters/ajax-crawling ) ...however I couldn't understand it and also feel loading site's sections through ajax would be a lot more work at this stage since my entire site is a static HTML file ( index.php ) with nothing rendered dynamically through javascript/AJAX
Someone who has faced similar problem can you suggest me the simplest and fastest way for my site's different sections ( eg .Clients , Partners , Contact Us etc ) to show up in google engine
Thanks in advance guys :)
Actually this question is more suitable for https://webmasters.stackexchange.com/ but since it has been raised here, I'll try and answer this question to the best of my knowledge.
Unfortunately, there is no shortcut for SEO and to be able to fetch search results in your favor is a slow and painful process. The basic principle of SEO is doing simple things right and provide quality content to your users in your website and not worry much about the ranking.
That being said, your expectation is slightly unrealistic for the following reasons,
You are asking Google to index a page that doesn't even exist.
The URL is changed with JavaScript on runtime, which is something no-search-enginebot is good at indexing.
However, there are couple of things that you can improve in terms of SEO (not going to guarantee what you have asked),
Make sure you have sitemap.xml file in the root directory of your website. You need to add individual sub-page links for each url like this,
<url>
<loc>http://germin8.com/clients</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
Once you are done with sitemap.xml file. Open your Google Webmaster Account (also make sure your Google Analytics account is linked to your webmaster profile) and validate the structure and schema of the sitemap file.
Write better anchor text - Add title attribute to your anchor tags. Avoid inline styles as much as you can. Use complete url instead of relative paths for href attribute.
Google doesn't like slow websites. Hence, you need to focus a lot on the performance of your website. Also no user likes to see a webpage loading for ages. Make efforts to concatenate, minify and lint your assets(html/css/js). Gzip compression is required as well.
149 requests with 4.1 MB is huge. You need to reduce the number of HTTP requests you make massively!
Conclusion
Apart from the above, I don't really see your internal links not being visible on search results as a big problem. Your primary objective is to make sure that your users land on your webpage (this is something that you already doing). After the user enters your territory (website) he has the liberty to navigate to any section of the webpage.
http://webcache.googleusercontent.com/search?q=cache:http://germin8.com&client=firefox-a&rls=org.mozilla:en-US:official&strip=1
I dont see any problem with indexing of your site. Clients will not showup in normal search but they would show up in google images. You should give alt tag to best describe the client images that you have used. Above url will give you an idea how Google bot sees your site. So you can notice all text is indexed by google including your heading where clients are listed. Hope this solves your concern.

Best practice for element that needs to use javascript only (restrictions apply) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Because of business rules and requirements, I need an element that is tab-able (without the use of tabindex), looks like a link, only has javascript functionality (it needs to make an ajax call to a web service for instance) and it cannot contain any special character such as '#' because the url will have that at the end and that will be blocked by our firewall which is set very strict due to external regulations.
Also the href cannot be empty because of our web site resides inside Sharepoint and keeping it empty means that you are redirected to the default landing page.
I've come across various questions which all contain some truth and arguments to use one element over the other, but none of those questions contained a satisfying answer, if it even had a marked answer. E.g.:
Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
Is an empty href valid?
those two examples are not completely satisfying because for the first one, eventhough one answer has a high amount of votes but I'm not sure if that answer meets the above requirements. the second one for the same reason really.
In summary, which of the below options is preferred, keeping the restrictions and requirements in mind as well as known best practices for semantics and javascript?
OR
OR
OR
<button class="action"></button>
OR
<span class="action"></span>
WITH (example) ajax call:
<script>
$('.action').click(function() {
$.ajax({
url: "test.html",
context: document.body
})
.done(function() {
$(this).addClass("done");
});
});
});
</script>
As mentioned the restrictions cannot be changed. Period.
I remember once a teacher told me that the best was to use a <a> tag ahd the href should point to a page that probably does the exact same thing as the javascript event. So if for any reason the javascript is desactivated on the browser, the user could still use the website as any normal website... but well that works fine on papers... but it would be hard to implement.
If you add javascript code on the href or onclick your user wont be able to open the link on a new tab (by using the middle button or with the context menu)... I personally hate that on a website... links should be used to "link" pages.. not to make javascript changes on the current page, so a <button> seems more semantic to me...
You should also consider SEO (maybe) because robots will try to follow your links to index pages, but they wont follow buttons. Seo is a gray area, but i'd not be surprised if the robots have a max limit of links to follow.. and if your page has lots of links that are used only for js, maybe the robots are not able to correctly index your site
Finally, I rather have unobtrusive Js, so I really try to separate behavior from presentation. I find it ugly when i see html and js together
So i'd go with:
<button class="action"></button>
with an event listener on JS... hey.. but that's just me :)
Hope this helps
Personally, I like to use <a href="javascript:void(null);"> for my JavaScript-powered links. I know it's overkill, I know that javascript:; would be just as sufficient, but it's a habit I picked up.
That said, if the JavaScript has a non-JavaScript alternative (such as a link that might take you to a form, that has JavaScript to pop up the form in a dialog), I would use that as the href and make sure to prevent the default action in the event handler.
<button> is not a good idea unless you specifically want it to look like a button - depending on your site, this may be a good or bad thing, but you get a lot more freedom by using <a> and CSS.
'a' tag with any href you want + event.preventDefault() on onclick function can help you, I think. Why 'a', becouse it good for styling you tabs headers, for example

How to get this effect (don't know what it is called?!?!) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
There is a site called http://www.nomomon.com, and when a user signs in there is a box that pops up saying 'connected to server', and welcome back etc etc...
To see what I mean go to the site and login with the email lazycg#live.co.uk and the password: pass
You will see what I mean, I just don't know how to go about creating this effect, any ideas??
One name for the technique you're thinking of would be "lightbox". There are many existing scripts to achieve such an effect. A quick search for "JavaScript lightbox" will return thousands of results.
Personally, I tend to use jQuery UI Dialog if I'm already using jQuery. Have a look at the modal example in the jQuery UI docs to find something similar to the example in your question.
This is a modal window: http://en.wikipedia.org/wiki/Modal_window
This a live example that you can use: http://jqueryui.com/demos/dialog/#modal-message
With some modification you could get a similar effect. Use a darker background, do some AJAX requests to update the message shown then redirect the user.
That effect is called a lightbox, it's obtainable by simply having an half transparent overlay over the page, and on top of that, a <div> which is animated with jQuery. The text changes, probably according to the AJAX call results, that's about all there is to it.
Their code in http://www.nomomon.com/ui/login.js is obscured, but I'd approach this with a tool like xajax ... http://www.xajax-project.org ... which can easily access call both PHP and javascript/jQuery functions. Doing a MySQL query, updating the DOM with jQuery, doing another MySQL query, updating the DOM again, etc.
The effect in jquery is called a lightbox. The one used on that site looks very similar to FancyBox. I'm willing to bet it is fancy box with a custom skin.

Categories