Sponsored Content
Top Forums Programming Python (seleniumrequests)Class, Constructor, Method Not Working Post 302953198 by metallica1973 on Wednesday 26th of August 2015 03:35:04 PM
Old 08-26-2015
Python (seleniumrequests)Class, Constructor, Method Not Working

Newbie question. I created a class:
Code:
class WP(seleniumrequests.PhantomJS):
    
                def __init__(self, wpurl='https://blah.org/download/release-archive/', bwppurl='https://blah.org/plugins/browse/popular/'):
                                self.wp=wpurl
                                self.bwpp=bwppurl
                def wpscaper(self):
                                wpjfetch=seleniumrequests.PhantomJS('../ms-tuesday/phantomjs/bin/phantomjs')
                                wpjfetch.get(self.wp)
                                wpsoup=BeautifulSoup(wpjfetch.page_source, 'lxml')
                def wppscaper(self):
                                wppjfetch=seleniumrequests.PhantomJS('../ms-tuesday/phantomjs/bin/phantomjs')
                                wppjfetch.get(self.bwpp)
                                wppsoup=BeautifulSoup(wpjfetch.page_source, 'lxml')

I am trying to understand why I cannot see any of my methods in where I would expect it to be:
Code:
goodies=WP()
goodies.wpscaper()
goodies.wpscaper.wpjfetch.page_source
goodies.wpscaper.wpsoup

What I see is:
Code:
goodies.wpscaper.im_class  goodies.wpscaper.im_func   goodies.wpscaper.im_self

and the same applies for:
Code:
goodies=WP()
goodies.wppscaper()
goodies.wppscaper.im_class  goodies.wppscaper.im_func   goodies.wppscaper.im_self

What gives ??

---------- Post updated 08-26-15 at 03:35 PM ---------- Previous update was 08-25-15 at 05:37 PM ----------

I can see that the stuff works. For example, if I add a print statement to the functions such as:
Code:
class WP(seleniumrequests.PhantomJS):
    
                def __init__(self, wpurl='https://blah.org/download/release-archive/', bwppurl='https://blah.org/plugins/browse/popular/'):
                                self.wp=wpurl
                                self.bwpp=bwppurl
                def wpscaper(self):
                                wpjfetch=seleniumrequests.PhantomJS('../ms-tuesday/phantomjs/bin/phantomjs')
                                wpjfetch.get(self.wp)
                                wpsoup=BeautifulSoup(wpjfetch.page_source, 'lxml')
                                print (wpsoup)
                def wppscaper(self):
                                wppjfetch=seleniumrequests.PhantomJS('../ms-tuesday/phantomjs/bin/phantomjs')
                                wppjfetch.get(self.bwpp)
                                wppsoup=BeautifulSoup(wpjfetch.page_source, 'lxml')
                                print (wppsoup)

it prints exactly whats in wpsoup or wppsoup:
Code:
goodies=WP()
goodies.wpscaper()
<!DOCTYPE html>
<html dir="ltr" lang="en" xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
<meta charset="utf-8"/>
<!--
<meta property="fb:page_id" content="6427302910" />
-->
<meta content="7VWES_-rcHBcmaQis9mSYamPfNwE03f4vyTj4pfuAw0" name="google-site-verification"/>
blah blah blah blah..
goodies.wppscaper()
<!DOCTYPE html>
<html dir="ltr" lang="en" xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
<meta charset="utf-8"/>
<!--
<meta property="fb:page_id" content="6427302910" />
-->
<meta content="7VWES_-rcHBcmaQis9mSYamPfNwE03f4vyTj4pfuAw0" name="google-site-verification"/>
blah blah blah blah..

Additonal Info:
Code:
In [180]: dir(goodies.wpscaper)
Out[180]: 
['__call__',
 '__class__',
 '__cmp__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__func__',
 '__get__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__self__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'im_class',
 'im_func',
 'im_self']
In [181]: dir(goodies.wppscaper)
Out[181]: 
['__call__',
 '__class__',
 '__cmp__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__func__',
 '__get__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__self__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'im_class',
 'im_func',
 'im_self']

So I simple cant understand why I dont have access to:

goodies.wpscaper.wpjfetch
goodies.wpscaper.wpsoup

or

goodies.wppscaper.wppjfetch
goodies.wppscaper.wppsoup

why cant I see them?? I am truly confused.

Last edited by metallica1973; 08-26-2015 at 04:43 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

call constructor of java class in script

Hi, Is it possible to call the constructur of a java class in a shell script? I know you can call static methods, but can you also call the constructor? tnx. (1 Reply)
Discussion started by: thebladerunner
1 Replies

2. Shell Programming and Scripting

Method isSuccess not working right perl

Good morning all.... I have been learning Perl for about 2 months now and I guess I am getting there as much as I can however I am really stuck. I have a Perl script called postEvent.pl which uses a package called event.pm. PostEvent.pl depends on a meithod inside event.pm called isSuccess to... (0 Replies)
Discussion started by: LRoberts
0 Replies

3. Programming

Pointer for class not working that well. Syntax I think.

I'll be gratefull for any help. Thanks. :) This is the non class type error: # g++ -I/usr/include/mysql -I/usr/include/mysql++ -lmysqlpp -L/usr/lib/mysql -L/usr/local/lib/mysql++ loaddsgsports.cpp -o loaddsgsports loaddsgsports.cpp: In function âint outputToImport(const char*, const char*,... (1 Reply)
Discussion started by: sepoto
1 Replies

4. Shell Programming and Scripting

[Python]StringVar() Class String processing

I have a requirement where I collect inputs from entry widget in gui(via variables a,b,c) and then output a string like this: -a a -b b -c c. Hence if I have given a=1 b=2 c=3, The output string is --> -a 1 -b 2 -c 3 or if I have given a=1 b=2 (c left blank) then the output is --> -a 1... (1 Reply)
Discussion started by: animesharma
1 Replies

5. Solaris

Python script not working in batch process

Good morning, I have a python 2.3 script that runs stand alone as intended when tested, then it was put into a ksh script. when running the ksh script it runs as intended. The problem is that my script does not run when the ksh script is called by another user who runs a batch process (as of right... (1 Reply)
Discussion started by: mhahe
1 Replies

6. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

7. Shell Programming and Scripting

Date Format not working in python script

Good Morning, I am working on a pyhton script, where it has to fetch a file from our vendor's server over an ftp. The file is having a date format of "MMDDYYYY" (i have included in my python script), but when the script is executed it is unable to fetch the file. At the same time, if i... (1 Reply)
Discussion started by: AReddy
1 Replies

8. Shell Programming and Scripting

Python: Comparison is not working for me

Guys it is very simple script , but for some reason my IF condition is not matching. from sys import argv import os filename='testdata.txt' txt=open(filename) while 1: line= txt.readline() if not line: break line=line.strip('\n') sp=line.split(" ") command =sp+ " " +sp+ " "... (4 Replies)
Discussion started by: baker
4 Replies

9. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

10. Shell Programming and Scripting

Challenge in finding listing class method and its number of code lines

there are about 300 objectivec .m files and I need to print each file name and its method and number of lines inside the method there is a sample perl files that do perl brace matching... (0 Replies)
Discussion started by: steve32001
0 Replies
All times are GMT -4. The time now is 07:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy