Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:46:16+00:00 2026-06-09T03:46:16+00:00

I have a web-app and initially I used feedparser to pull data from my

  • 0

I have a web-app and initially I used feedparser to pull data from my blog. Now I thought to use Google API for extending various other features.

As I didn’t want to break my old code and want to add the new API as an additional add-on type thing, I thought to setup a structure very similar to BeautifulSoup where it provides a choice to select an HTML/ XML parser depending upon the situation

BeautifulSoup(markup, "html.parser") 
BeautifulSoup(markup, "lxml")
# They still support the same methods mentioned in the documentation.

This is what I did:

from apis import api1, api2
from dev_user import my_api_choice
select = { "api1" : api1, "api2": api2 }

obj = pservice (select["my_api_choice"] )
obj.method1() 
# invokes method1 of the inherited class.

pservice is very close to wrap-up class. I initially thought to write it because I could have a chance to use Google API in it.

I even made sure that api2 (which provides Google API functionality) provides same kind of methods as that of api1 (even their method names are same).

So, is this a good way to do it? or else, how can I possibly do it in the other way..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:46:17+00:00Added an answer on June 9, 2026 at 3:46 am

    You may create an abstract class API with some abstract method like fetch or pull and inherit it and build concrete implementations under classes like API1 / API2 / etc…

    For example implementation of fetch function for Google API would be done for HTML and same way fetch function for feedparser would be implemented using XML…

    Now based on your requirement or current configuration or whatever input; make a decision which API you want to use and create dynamic instance for the same, now as method names would be same in all classes you just need to fire appropriate function for that instance and you’re done.

    Further more, afterwards you can introduce API3 and update your configuration – to use API3 class instance as another content provider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app that reads data from a SQL DB that contains
I have a web app in production that is used for typical data entry,retrieval,
If you have used the Google Maps web app on your iphone or ipad
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
I have a web app that runs fine in Visual web developer. But when
I have a web app built with Dojo 1.7.2, using RequireJS to load individual
I have another web app, that uses the liferay user database. But before a
I have a web app. I am using JSF2 framework. My problem started when
I have a web app, where I keep a subdomain for every client eg:
I have a web app that has a big and complex form (fields, checks,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.