Reading xpath value error - Lxml

2013-04-14 Thread bubufff
Hi all, 

I am trying to crawl the information from this link 

http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781

and this is the code I use

link = 
> "http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781;
> xPath =  "id('pC_DV_tableHeader')/x:tbody/x:tr[4]/x:td[3]"
> namespace = {'x': 'http://www.w3.org/1999/xhtml'}
>
> tree = lxml.html.parse(link)
> arrayContent = tree.xpath(xPath + "/text()", namespaces=namespace)
>
> if len(arrayContent):
>  content = cgi.escape(arrayContent[0].encode("utf-8"))
>

I use xPath checker add-on of firefox to read the xPath value and the 
namespace. However, when running the code, I always get the content empty. 
How can I solve this ?  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Circular import problem

2013-04-13 Thread bubufff
Thank all, I just moved the import to the local function and it works. 
Still re-factoring the codes to overcome this issue completely 

On Friday, April 12, 2013 1:08:26 AM UTC+7, bub...@gmail.com wrote:
>
> Hi all,
>
> I have a util file, which will do some stuffs and then, update a model (so 
> i have to import the models in this file). Also, in my models file, I 
> trigger a post_save signal to call the util file file (so I have to import 
> this file in the models file). Obviously, I will get a circle import 
> problem. Therefore, what is the best practices in this situation ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Circular import problem

2013-04-11 Thread bubufff
Hi all,

I have a util file, which will do some stuffs and then, update a model (so 
i have to import the models in this file). Also, in my models file, I 
trigger a post_save signal to call the util file file (so I have to import 
this file in the models file). Obviously, I will get a circle import 
problem. Therefore, what is the best practices in this situation ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.