Sponsored Content
Top Forums Programming Python (seleniumrequests)Class, Constructor, Method Not Working Post 302953486 by metallica1973 on Friday 28th of August 2015 12:31:05 PM
Old 08-28-2015
Aia, I still cant unhide the methods under wppscaper or wpscaper with any return or restructuring this in anyway:
Code:
class WP(seleniumrequests.PhantomJS):
        
                      def __init__(self):
                                                        self.wpurl='https://blah.org/download/release-archive/'
                                                        self.wppurl='https://blah.org/plugins/browse/popular/'
                      def wpscaper(self):
                                                        wpinit=seleniumrequests.PhantomJS(executable_path='phantomjs/bin/phantomjs')
                                                        wpinit.get(self.wpurl)
                                                        wpsoup=BeautifulSoup(wpinit.page_source, 'lxml')
                                                        print (wpsoup)
                                                        return wpsoup
                      def wppscaper(self):
                                                        wppinit=seleniumrequests.PhantomJS(executable_path = "phantomjs/bin/phantomjs")
                                                        wppinit.get(self.wppurl)
                                                        wppsoup=BeautifulSoup(wppinit.page_source, 'lxml')
                                                        print (wppsoup)
                                                        return wppsoup

In [85]: dir(WP)
Out[85]: 
['__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_unwrap_value',
 '_wrap_value',
 'add_cookie',
 'application_cache',
 'back',
 'close',
 'create_web_element',
 'current_url',
 'current_window_handle',
 'delete_all_cookies',
 'delete_cookie',
 'desired_capabilities',
 'execute',
 'execute_async_script',
 'execute_script',
 'file_detector',
 'find_element',
 'find_element_by_class_name',
 'find_element_by_css_selector',
 'find_element_by_id',
 'find_element_by_link_text',
 'find_element_by_name',
 'find_element_by_partial_link_text',
 'find_element_by_tag_name',
 'find_element_by_xpath',
 'find_elements',
 'find_elements_by_class_name',
 'find_elements_by_css_selector',
 'find_elements_by_id',
 'find_elements_by_link_text',
 'find_elements_by_name',
 'find_elements_by_partial_link_text',
 'find_elements_by_tag_name',
 'find_elements_by_xpath',
 'forward',
 'get',
 'get_cookie',
 'get_cookies',
 'get_log',
 'get_screenshot_as_base64',
 'get_screenshot_as_file',
 'get_screenshot_as_png',
 'get_window_position',
 'get_window_size',
 'implicitly_wait',
 'log_types',
 'maximize_window',
 'mobile',
 'name',
 'orientation',
 'page_source',
 'quit',
 'refresh',
 'request',
 'save_screenshot',
 'set_page_load_timeout',
 'set_script_timeout',
 'set_window_position',
 'set_window_size',
 'start_client',
 'start_session',
 'stop_client',
 'switch_to',
 'switch_to_active_element',
 'switch_to_alert',
 'switch_to_default_content',
 'switch_to_frame',
 'switch_to_window',
 'title',
 'window_handles',
 'wppscaper',
 'wpscaper']

In [86]: dir(WP.wpscaper)
Out[86]: 
['__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 [87]: dir(WP.wppscaper)
Out[87]: 
['__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']

I think I understand code encapulation but in this instance I dont want it but for the life of me I cannot understand why I can see my methods and or anything under wpscaper and or wppscaper ? also why cannot I see wpsoup and or wppsoup under wpscaper or wppscaper? Please shed further light upon meSmilie
 

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 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy