QuickMacro Android version from api interface to obtain keyword expansion terms

Do web promotion friends may know the long tail word is spreading word keywords, search on Baidu today when api interface to see a Taobao commodity word keyword expansion interface.

http://suggest.taobao.com/sug?code=utf-8&q= commodity keywords & callback = cb

Because it is free interface, we used to write a script, how to try the effect:

Looked at the form interface parameters have been written to the interface URL, you can get directly get.

First look at the extracted format, of course, to get way, there is a simple way is to directly copy the URL into a browser inside, run to open the web site is also possible.

Look return value format is json, but it feels more cb (), with regular match simple extraction process it, and then extract the contents inside want.

Here to talk about a little, this regular expression.

First look at the whole paragraphs:

cb ({ "result": [[ "fan desktop", "123,507.58474403426"], [ "fan home", "189,269.83877199035"], [ "fan landing", "178,662.51393884892"], [ "fan small", "217,246.06335985026" ], [ "fan dormitory bed student", "42896.32537188351"], [ "fan light", "299,337.5123540592"], [ "fans holding", "57536.23212172443"], [ "fan cooling", "21897.660492157924"], [ " light fan home restaurant "," 44998.50050403226 "], [" Ceiling fan "," 32837.63664962642 "]]})

Extract content in brackets, that is, cb ( to extract content ),

Look at the regular expression: ShanHai.RegexFind (m, "cb% ((.-)%)"),

Effective in which expression is cb% ((.-)%), this is how come it is so, such as a piece, I think part of it is extracted, will encase part to be extracted in parentheses, and then use ... to replace.

For example, I want the public the following number of names of these words.

Original content: Hello everyone, I am a public school No. 3 minutes of the main reason people Guo Li staff.

Extract content: (. *) Hello everyone, I am a public number is the main reason people Guo Li staff.

The (*) represents the content I want to extract, you may find that careful if I write the source code is not (. *), But (.-), it is all the same in this case, the meaning of point in any format, and * -, and a +, which is the number of matches, is put together any arbitrary number of formats, represents any content (*).

After the match by a regular, get the json content, the first step is to turn the table type

dim tb = Encode.JsonToTable(a(0))

The json's a lot of content, tidy format:

Manual finishing this thing is too much trouble, with what tools, http: //www.bejson.com/ through this web site can be a key format. Then you can extract json, and quite a few have talked about before, here not elaborate.

This is an extract, extract all, then use a for loop.

For convenience, the key words alone raised a variable, so in the future would like to use what keywords can be a direct replacement value of the variable on the line.

Get keyword tidy, currently there are two issues, namely, keyword spaces, and second descriptors are in the back, feeling word order in question, such as desktop fans, desk fans should be.

Well, this step basically completed, and follow-up may be the key words written text.

The code in this article may not be useful for all of us, it is a major study notes, recording the process of writing the script and thinking operation.

Published 28 original articles · won praise 3 · views 10000 +

Guess you like

Origin blog.csdn.net/biao197/article/details/101797575