Fetch data from twse.com.tw
        return list.
        從 twse.com.tw 下載資料，回傳格式為 list
162950
def fetch_data(self, stock_no, nowdatetime, firsttime = 1):
    
    url = 'http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report%(year)d%(mon)02d/%(year)d%(mon)02d_F3_1_8_%(stock)s.php&type=csv&r=%(rand)s' % {'year': nowdatetime.year, 'mon': nowdatetime.month, 'stock': stock_no, 'rand': random.randrange(1,1000000)}
    self.debug_print(url)
    logging.info(url)
    #print cc.info().headers

    # set memcache expire
    now = TWTime().now
    if now >= datetime(now.year, now.month, now.day, 14, 45):
      addday = 1
    else:
      addday = 0
    endtime = datetime(now.year, now.month, now.day, 14, 00) + timedelta(days = addday) ## change from 13:35 to 14:00
    logging.info('endtime: %s' % str(endtime))

    if firsttime == 0:
      if endtime <= now:
        expire = 'ALUP' ## always update.
      else:
        expire = (endtime - now).seconds
    else:
      expire = 0 ## never expire.
    logging.info('expire: %s' % expire)

    ## get memcache
    memname = '%(stock)s%(year)d%(mon)02d' % {'year': nowdatetime.year, 'mon': nowdatetime.month,'stock': stock_no}
    stkm = memcache.get(memname)
    if stkm:
      csv_read = csv.reader(stkm)
      logging.info('#MemcacheGet: %s' % memname)
    else:
      cc = urllib2.urlopen(url)
      cc_read = cc.readlines()
      csv_read = csv.reader(cc_read)
      if expire != 'ALUP':
        memcache.add(memname, cc_read, expire)
      else:
        memcache.delete(memname)
      memcache.add('time%s' % memname, '%s %s' % (now, expire))
      logging.info('#MemcacheAdd: %s' % memname)

    return csv_read
1194962
def GetList(self):
        

        # Build Request
        soap_request = soap('GetList')
        soap_request.add_parameter('listName', self.listName)
        self.last_request = str(soap_request)

        # Send Request
        response = self._session.post(url=self._url('Lists'),
                                      headers=self._headers('GetList'),
                                      data=str(soap_request),
                                      verify=self._verify_ssl,
                                      timeout=self.timeout)

        # Parse Response
        if response.status_code == 200:
            envelope = etree.fromstring(response.text.encode('utf-8'), parser=etree.XMLParser(huge_tree=self.huge_tree))
            _list = envelope[0][0][0][0]
            info = {key: value for (key, value) in _list.items()}
            for row in _list[0].getchildren():
                self.fields.append({key: value for (key, value) in row.items()})

            for setting in _list[1].getchildren():
                self.regional_settings[
                    setting.tag.strip('{http://schemas.microsoft.com/sharepoint/soap/}')] = setting.text

            for setting in _list[2].getchildren():
                self.server_settings[
                    setting.tag.strip('{http://schemas.microsoft.com/sharepoint/soap/}')] = setting.text
            fields = envelope[0][0][0][0][0]

        else:
            raise Exception("ERROR:", response.status_code, response.text)
1286738
def _fetch_stock_data(self, stock_list):
        """"""
        res = super()._fetch_stock_data(stock_list)

        with_stock = []
        for stock, resp in zip(stock_list, res):
            if resp is not None:
                with_stock.append((stock, resp))
        return with_stock
281857
def fetch(self):
        
        return self.domain._record(self.doapi_manager.request(self.url)\
                                                             ["domain_record"])
524719
def GetListItems(self, viewname=None, fields=None, query=None, rowlimit=0, debug=False):
        

        # Build Request
        soap_request = soap('GetListItems')
        soap_request.add_parameter('listName', self.listName)
        # Convert Displayed View Name to View ID
        if viewname:
            soap_request.add_parameter('viewName', self.views[viewname]['Name'][1:-1])

        # Add viewFields
        if fields:
            # Convert to SharePoint Style Column Names
            for i, val in enumerate(fields):
                fields[i] = self._disp_cols[val]['name']
            viewfields = fields
            soap_request.add_view_fields(fields)
            # Check for viewname and query
            if [viewname, query] == [None, None]:
                # Add a query if the viewname and query are not provided
                # We sort by 'ID' here Ascending is the default
                soap_request.add_query({'OrderBy': ['ID']})

        elif viewname:
            viewfields = self.GetView(viewname)['fields']  ## Might be wrong
        else:
            # No fields or views provided so get everything
            viewfields = [x for x in self._sp_cols]

        # Add query
        if query:

            if 'Where' in query:
                where = etree.Element('Where')

                parents = []
                parents.append(where)
                for i, field in enumerate(query['Where']):
                    if field == 'And':
                        parents.append(etree.SubElement(parents[-1], 'And'))
                    elif field == 'Or':
                        if parents[-1].tag == 'Or':
                            parents.pop()
                        parents.append(etree.SubElement(parents[-1], 'Or'))
                    else:
                        _type = etree.SubElement(parents[-1], field[0])
                        field_ref = etree.SubElement(_type, 'FieldRef')
                        field_ref.set('Name', self._disp_cols[field[1]]['name'])
                        if len(field) == 3:
                            value = etree.SubElement(_type, 'Value')
                            value.set('Type', self._disp_cols[field[1]]['type'])
                            value.text = self._sp_type(field[1], field[2])

                query['Where'] = where

            soap_request.add_query(query)

        # Set Row Limit
        soap_request.add_parameter('rowLimit', str(rowlimit))
        self.last_request = str(soap_request)

        # Send Request
        response = self._session.post(url=self._url('Lists'),
                                      headers=self._headers('GetListItems'),
                                      data=str(soap_request),
                                      verify=self._verify_ssl,
                                      timeout=self.timeout)

        # Parse Response
        if response.status_code == 200:
            envelope = etree.fromstring(response.text.encode('utf-8'), parser=etree.XMLParser(huge_tree=self.huge_tree))
            listitems = envelope[0][0][0][0][0]
            data = []
            for row in listitems:
                # Strip the 'ows_' from the beginning with key[4:]
                data.append({key[4:]: value for (key, value) in row.items() if key[4:] in viewfields})

            self._convert_to_display(data)

            if debug:
                return response
            else:
                return data
        else:
            return response
171625
def get_next(self):
        """"""
        url = self._get_link('next')
        resource = self.object_type.get_resource_class(self.client)
        resp = resource.perform_api_call(resource.REST_READ, url)
        return List(resp, self.object_type, self.client)
520147
def data_fetch(self, url, task):
        ''''''
        self.on_fetch('data', task)
        result = {}
        result['orig_url'] = url
        result['content'] = dataurl.decode(url)
        result['headers'] = {}
        result['status_code'] = 200
        result['url'] = url
        result['cookies'] = {}
        result['time'] = 0
        result['save'] = task.get('fetch', {}).get('save')
        if len(result['content']) < 70:
            logger.info("[200] %s:%s %s 0s", task.get('project'), task.get('taskid'), url)
        else:
            logger.info(
                "[200] %s:%s data:,%s...[content:%d] 0s",
                task.get('project'), task.get('taskid'),
                result['content'][:70],
                len(result['content'])
            )

        return result
314215
def list(self, verbose=False):
        

        response=api(url=self.__url+"/list", method="POST", verbose=verbose)
        return response
906079
def fetch_data(self, **var):
        """"""
        varstr = ','.join(name + self._convert_indices(ind)
                          for name, ind in var.items())
        query = self.query().add_query_parameter(req='data', var=varstr)
        return self._fetch(query)
224585
def getList(self):
        

        desc = {
            "name": "ListWordfilterReslut",
            "desc": "listWordfilter返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "word",
                "type": "String",
                "desc": "敏感词内容。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/x-www-form-urlencoded'),
            action='/wordfilter/list.json',
            params={})
        return Response(r, desc)
698488
def fetch_data(self):
        """"""
        # Get http session
        yield from self._get_httpsession()
        # Get login page
        login_url = yield from self._get_login_page()
        # Post login page
        yield from self._post_login_page(login_url)
        # Get p_p_id and contracts
        p_p_id, contracts = yield from self._get_p_p_id_and_contract()
        # If we don't have any contrats that means we have only
        # onecontract. Let's get it
        if contracts == {}:
            contracts = yield from self._get_lonely_contract()

        # Get balance
        balances = yield from self._get_balances()
        balances_len = len(balances)
        balance_id = 0
        # For all contracts
        for contract, contract_url in contracts.items():
            if contract_url:
                yield from self._load_contract_page(contract_url)

            # Get Hourly data
            try:
                yesterday = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1)
                day_date = yesterday.strftime("%Y-%m-%d")
                hourly_data = yield from self._get_hourly_data(day_date, p_p_id)
                hourly_data = hourly_data['processed_hourly_data']
            except Exception:  # pylint: disable=W0703
                # We don't have hourly data for some reason
                hourly_data = {}

            # Get Annual data
            try:
                annual_data = yield from self._get_annual_data(p_p_id)
            except PyHydroQuebecAnnualError:
                # We don't have annual data, which is possible if your
                # contract is younger than 1 year
                annual_data = {}
            # Get Monthly data
            monthly_data = yield from self._get_monthly_data(p_p_id)
            monthly_data = monthly_data[0]
            # Get daily data
            start_date = monthly_data.get('dateDebutPeriode')
            end_date = monthly_data.get('dateFinPeriode')
            try:
                daily_data = yield from self._get_daily_data(p_p_id, start_date, end_date)
            except Exception:  # pylint: disable=W0703
                daily_data = []
            # We have to test daily_data because it's empty
            # At the end/starts of a period
            if daily_data:
                daily_data = daily_data[0]['courant']
            # format data
            contract_data = {"balance": balances[balance_id]}
            for key1, key2 in MONTHLY_MAP:
                contract_data[key1] = monthly_data[key2]
            for key1, key2 in ANNUAL_MAP:
                contract_data[key1] = annual_data.get(key2, "")
            # We have to test daily_data because it's empty
            # At the end/starts of a period
            if daily_data:
                for key1, key2 in DAILY_MAP:
                    contract_data[key1] = daily_data[key2]
            # Hourly
            if hourly_data:
                contract_data['yesterday_hourly_consumption'] = hourly_data
            # Add contract
            self._data[contract] = contract_data
            balance_count = balance_id + 1
            if balance_count < balances_len:
                balance_id += 1
1152409
def fetch(self, url):
        '''
        
        '''
        opener = self._urllib.build_opener()
        opener.addheaders = self._requestHeaders.items()
        response = opener.open(url)
        headers = response.info()
        raw = response.read()
        raw = raw.decode('utf8')

        if not 'Content-Type' in headers:
            raise OEmbedError('Missing mime-type in response')

        if headers['Content-Type'].find('application/xml') != -1 or \
           headers['Content-Type'].find('text/xml') != -1:
            response = OEmbedResponse.newFromXML(raw)
        elif headers['Content-Type'].find('application/json') != -1 or \
             headers['Content-Type'].find('text/javascript') != -1 or \
             headers['Content-Type'].find('text/json') != -1:
            response = OEmbedResponse.newFromJSON(raw)
        else:
            raise OEmbedError('Invalid mime-type in response - %s' % headers['Content-Type'])

        return response
1349394
def fetch_tweets(account_file, outfile, limit):
    
    print('fetching tweets for accounts in', account_file)
    outf = io.open(outfile, 'wt')
    for screen_name in iter_lines(account_file):
        print('\nFetching tweets for %s' % screen_name)
        for tweet in twutil.collect.tweets_for_user(screen_name, limit):
            tweet['user']['screen_name'] = screen_name
            outf.write('%s\n' % json.dumps(tweet, ensure_ascii=False))
            outf.flush()
1373442
def _fetch_itemslist(self, current_item):
        
        if current_item.is_root:
            html = requests.get(self.base_url).text
            soup = BeautifulSoup(html, 'html.parser')
            for item_html in soup.select(".row .col-md-6"):
                try:
                    label = item_html.select_one("h2").text
                except Exception:
                    continue
                yield API(label, blob=item_html)
        else:
            # parameter = current_item.parent
            # data = requests.get(parameter.url)
            for resource in current_item.json["resource"]:
                label = u"{}, {}".format(resource["title"], resource["summary"])
                yield SMHIDataset(label, blob=resource)
1273465
def list(self, search_from=None, search_to=None, limit=None):
        
        l = []
        for i in self._list():
            l.append(i['data']['data'])
        return l[0:limit]
97501
def GetListCollection(self):
        """"""
        # Build Request
        soap_request = soap('GetListCollection')
        self.last_request = str(soap_request)

        # Send Request
        response = self._session.post(url=self._url('SiteData'),
                                      headers=self._headers('GetListCollection'),
                                      data=str(soap_request),
                                      verify=self._verify_ssl,
                                      timeout=self.timeout)

        # Parse Response
        if response.status_code == 200:
            envelope = etree.fromstring(response.text.encode('utf-8'), parser=etree.XMLParser(huge_tree=self.huge_tree))
            result = envelope[0][0][0].text
            lists = envelope[0][0][1]
            data = []
            for _list in lists:
                _list_data = {}
                for item in _list:
                    key = item.tag.replace('{http://schemas.microsoft.com/sharepoint/soap/}', '')
                    value = item.text
                    _list_data[key] = value
                data.append(_list_data)

            return data
        else:
            return response
312474
def fetch():
    
    mir, r, slackpkg_last_date = mirror(), "", ""
    count, upgraded = 0, []
    if mir:
        tar = urlopen(mir)
        try:
            r = tar.read()
        except AttributeError:
            print("sun: error: can't read mirror")
    if os.path.isfile(var_lib_slackpkg + changelog_txt):
        slackpkg_last_date = read_file("{0}{1}".format(
            var_lib_slackpkg, changelog_txt)).split("\n", 1)[0].strip()
    else:
        return [count, upgraded]
    for line in r.splitlines():
        if slackpkg_last_date == line.strip():
            break
        if (line.endswith("z:  Upgraded.") or line.endswith("z:  Rebuilt.") or
                line.endswith("z:  Added.") or line.endswith("z:  Removed.")):
            upgraded.append(line.split("/")[-1])
            count += 1
        if (line.endswith("*:  Upgraded.") or line.endswith("*:  Rebuilt.") or
                line.endswith("*:  Added.") or line.endswith("*:  Removed.")):
            upgraded.append(line)
            count += 1
    return [count, upgraded]