Style Google dictionary API results - dictionary

I have no idea what I am doing, but I keep trying. I have been trying to find a way to add a dictionary search box to my school website for my 3rd grade (7-8 year olds). Most of the dictionary sites are too complex and riddled with inappropriate advertisements. I found out about google/dictionary.com the other day and have been trying to figure out how to create a custom search with it.
I asked for help here before and was able to get a script that passed a word to the dictionary and displayed the results in an Iframe. Which works ok but it is a full page and I can't change the size of the page in the Iframe.
I came across this
http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q=school&sl=en&tl=en&restrict=pr%2Cde&client=te
Where "school" is the word that is looked up.
However I can't figure out how to style the results, any ideas?

I suggest you dont use this url(API) as it is against google policy. It violates the contract google has with its providers, google asked a developer who made a dictionary extension for chrome to stop using the api.

The result is coming back in JSON. You'll probably want something that can parse JSON, and then you can output the result in whatever form you like, based on the data from the result.

You need to be a little conversant with javascript since the results are sent back as a javascript object ie the result is sent back as json text which you need to parse to retrieve the contents. To parse the contents you can use the javascript eval() function.

Related

What is "dlta" and "ridlist" parameters used in Requests library (Python)

Guys I am working on getting data as tables from QuickBase using Requests library (Python). I found somebody doing it using the URL of the report, but he added two parameters to the URL like that:
&dlta=xs%xx&ridlist=xxxx.
Can anybody please tell me what are those two parameters, I searched for them in the internet but found nothing related to them.
I've been using Quickbase for over ten years and haven't seen documentation for either of these parameters. I have noticed that ridList seems to be used by Quickbase's grid edit view of reports (I suspect it's an ID for a server-side cached list of record IDs to display especially when using the type-ahead search of a report before choosing to grid edit) and dlta is used in the "Download report as CSV" button.
That example you're following may have simply copy and pasted a link generated by Quickbase as a hack to get a CSV instead of XML response. I recommend following the Quickbase HTTP API Reference instead. If you don't want an XML response, Quickbase also has a JSON RESTful API which may be easier to work with.

How to define google_tag_params in Google Tag Manager?

i want to create a dynamic remarketing campaign in Google Ads, but i have to let GTM know where to extract the information for ecomm_prodid, ecomm_pagetype, ecomm_totalvalue and ecomm_category from my website. I understand that i have to create a Data Layer Variable but i just don't know how to make those tags extract the necessary info from my website. I also know that you should be able to see in Google Tag Assistant the Metadata for your products (price, brand, category etc) in the Dynamic Remarketing Tag. Unfortunately i cannot add code to my website as it was created on a platform that doesn't allow custom code, so i have to use GTM.
For example the class for the price is: fPrice -g-product-final-price-258. Shouldn't ecomm_totalvalue take info from this class? I tried reading Help pages from google but they are soooo confusing, i cannot understand them.
If anyone would help me with this i would be very grateful.
Thanks
I know this is 10 months late but this might help you or lead someone arriving here to hopefully the right direction and/or solution. I came across your question unanswered when looking for something else. It seems you have two questions so I'll try to answer both.
For starters you might want to have a quick look at the GTM Dynamic Remarketing Documentation.
Question 1: Where to extract the information for [variables] ?
You are on the right track with the dataLayer here. Usually you need to implement that with custom Javascript on your website (which in your case you can't do / see below for that). You would usually populate a events & variables with dataLayer.push() function.
Here is a sample of how that could look:
dataLayer.push({
'event': 'your_event_name',
'a_container_name' : {
'key1' : key_var_1,
'key2' : key_var_2, }
})
You can also do inner structures within those structures (nested dictionary).
Once those are populated you can create variables in Google Tag Manager (GTM) and simply pick up the values with the naming convention you've used separated by a "." (dot). For the above you could for example do: "a_container_name.key1" which would then populate the variable in GTM with the value of "key_var_1".
You can use the event name (here: 'your_event_name') as the trigger for the Tag in GTM to fire your Tag.
So in your case you would usually want the variable "ecomm_prodid" taken from the webpage with a bit of javascript and pushed into the dataLayer for you to pick up in GTM as described.
Question 2: I cannot add code to my website, what can I do ?
While this is entirely possible it is unfortunately a bit more tedious and potentially much more error prone. In this case you have to read the values you want directly from your website through GTM.
You can use custom javascript inside variables in GTM. To do so click on "variables", then click on "New" and select "Custom Javascript". You can then use pretty much any javascript here to basically scrape the value off your website based on id, class or any other HTML identifiers. There are tons of options on how to do that. You have to use what works best for you.
However this is potentially very error prone. Here is why:
You've stated that your class for the price is "fPrice -g-product-final-price-258". This looks to me very much like an auto generated identifier. Next time you look at that product or pick another one it is most likely different. So your option is to take either another unique identifier or use a sub-string of that one (e.g.: fPrice -g-product-final-price only). But keep in mind if your website ever updates or changes those class names the javascript you wrote instantly will not work any longer.
So it is important to pick some robust form of identifier or write the javascript code so that it will last. As mentioned, the jvascript to scrape or read directly off your website can be as custom as you like. Here is a crude example of how this would look like.
var text = ''; // empty value placeholder
if (document.getElementsByClassName("YOUR_SPECIFIC_CLASS_NAME")) {
....loop through returned elements if applicable....
....do stuff here or check stuff here...
text = SOME_ELEMENT.innerHTML;
console.log(text) // helps to debug your code
}
return text
Again this is only a crude example but if you get this to work then you can simply use the populated variable in your Tag in any field that supports variable with the double curly brackets: {{YOU_TAG_MANAGER_VARIABLE_NAME}}
I hope this helps and gives you a bit on an insight. Good luck!
PS: By the way. If you can't edit your code because of your website provider or website engine then I would strongly recommend moving away from it. As you can see it would save you a ton of headache. For smaller to mid sites and smaller e-commerce stores use Wordpress. For larger stuff there are other solutions. In any case there are some website builders out there that are simply really bad but at the same time very misleading. Basically leading you to the problems as you've described. Don't use them :)

How do I search with the "&" keyword, e.g I want food & drink

In bootstrap-table jquery (http://issues.wenzhixin.net.cn/bootstrap-table/)
How do I search with the "&" keyword, e.g I want food & drink.
However, when read the source code, it has .replace for /&/ to &. Any idea I can bypass this? It is impossible to ask user to key in & in the search text box.
So... im still a little unclear as there is no bug in core code.
See this fiddle which proves "&" search works fine:
http://jsfiddle.net/dabros/x8efv6wf/1/
If this somehow doesnt answer your needs, elaborate on exactly why.
Then look at some extensions like multiple search, filter and filter-control:
http://bootstrap-table.wenzhixin.net.cn/extensions/
If still not happy, then create a custom search function. Easy to do if using server-side pagination, but possible even if client-side.
If you fixed on using client-side (not server side pagination + search, meaning that the js does the search, not your own server code) then look at custom search.
Relatively new feature i think, not used it myself as if i wanted a custom search i would use server-side code.
But here it is:
Custom search function #1956
https://github.com/wenzhixin/bootstrap-table/issues/1956
How to search within row details? #2007
https://github.com/wenzhixin/bootstrap-table/issues/2007
https://github.com/wenzhixin/bootstrap-table/pull/1979
That pull requests seems most detailed, it appears full example still otw, but shouldnt be hard if you read through there.
Though frankly, stick with plugins/extensions i listed above or use server-side code if still not happy - gives you far greater control with far simpler execution/code-maintenance.

Aggregating from various sources

It could be a project well beyond my skills right now but I've got around one full month to spend on it so I think I can do it. What I want to build is this: Gather news about a specific subject from various sources. Easy, right? Just get the rss feeds and display them on a page. Well, I want something more advanced: Duplicates removed and customized presentation (that is, be able to define/change the format in which the news headlines are displayed).
I've played a bit with Yahoo Pipes and some other tools and I am facing two big problems:
Some sources don't provide rss feeds. How do I create one?
What's the best method to find and remove duplicates. I thought about comparing the headlines and checking if there is a matching bigger than, say, 50%. Is that a good practice though?
Please add any other things (problems, suggestions, whatever) I might not have considered.
Duplication is a nasty issue. What I eventually ended up doing:
1. Strip out all HTML tags except for links (Although I started using regex, I was burned. I eventually moved to custom parsing to remove tags)
2. Strip out all whitespace
3. Case-desensitize
4. Hash all that with MD5.
Here's why you leave the link in:
A comment might be as simple as "Yes, this sucks". "Yes, this sucks" could be a common comment. BUT if the text "this sucks" is linked to different things, then it is not a duplicate comment.
Additionally, you will find that HTML tag escaping is weird with RSS feeds. You would think that a stray < would be double-encoded: (I think)&<;
But it is not. It is encoded <
But so too are HTML tags! :<p>
I eventually copied all the known HTML tags as parsed by Mozilla Firefox and manually recognized those tags.
Creating an RSS feed from HTML is quite nasty and I can only point you to services such as Spinn3r, which are fantastic at de-duplication and content extraction. These services typically use probability-based algorithms that are above me. I know of one provider that got away with regexing pages (They had to know that a certain page was MySpace-based or Blogger-based) but they did not perform admirably.
You might want to try to use the YQL module to scrape a webpage that doesn't provide RSS. Here's a sample of a YQL statement to scrape HTML.
About duplicates, take a look at this pipe.
Customized presentation: if you want it truly customized you'll have to manipulate the pipe results yourself, e.g. get it as JSON an manipulate it with Javascript, or process it server-side.

ASP.NET: Looking for solution to solve XSS

We got a long-running website where XSS lurks. The problem comes from that some developers directly - without using HtmlEncode/Decode() - retrieve Request["sth"] to do the process, putting on the web.
I wonder if there is any mechanism like HTTPModule to help us HtmlEncode() all the items in a Http request to avoid XSS to some extent.
Appreciate for any suggestion.
Rgds,
Ricky
The problem is not retrieving Request data without HTML-encoding. In fact that's perfectly correct. You should not encode any text until the final output stage when you spit it into an HTML page.
Trying to blanket-encode incoming parameters, whether that's HTML-encoding or SQL-encoding, is totally the wrong thing. It may hide XSS holes in your app but it does not fix them. You will still have a hole if you output content that hasn't come from parameters, or has been processed since then. Meanwhile the automatic encoding will fill your database with multiply-escaped &amp;amp;amp;amp;amp;amp; crud.
You need to fix the output stage, that's where the problem lies.
Like bobince said, this is an output problem, not an input problem. If you can isolate where this data is being output on the page, you could create a Filter and add it to the Response object. This filter would isolate the areas that are common output and then HtmlEncode them.

Resources